Embedded Variables
The ngx_http_core_module
module supports embedded variables with names matching the Apache Server variables. First of all, these are variables representing client request header fields, such as $http_user_agent
, $http_cookie
, and so on. Also there are other variables:
-
argument
name
in the request line - arguments in the request line
- client address in a binary form, value’s length is always 4 bytes for IPv4 addresses or 16 bytes for IPv6 addresses
-
number of bytes sent to a client, not counting the response header; this variable is compatible with the “
%B
” parameter of themod_log_config
Apache module - number of bytes sent to a client (1.3.8, 1.2.5)
- connection serial number (1.3.8, 1.2.5)
- current number of requests made through a connection (1.3.8, 1.2.5)
- “Content-Length” request header field
- “Content-Type” request header field
-
the
name
cookie - root or alias directive’s value for the current request
-
same as
$uri
- in this order of precedence: host name from the request line, or host name from the “Host” request header field, or the server name matching a request
- host name
- arbitrary request header field; the last part of a variable name is the field name converted to lower case with dashes replaced by underscores
-
“
on
” if connection operates in SSL mode, or an empty string otherwise -
“
?
” if a request line has arguments, or an empty string otherwise - setting this variable enables response rate limiting; see limit_rate
- current time in seconds with the milliseconds resolution (1.3.9, 1.2.6)
- nginx version
- PID of the worker process
-
“
p
” if request was pipelined, “.
” otherwise (1.3.12, 1.2.7) -
client address from the PROXY protocol header, or an empty string otherwise (1.5.12)
The PROXY protocol must be previously enabled by setting the
proxy_protocol
parameter in the listen directive. -
client port from the PROXY protocol header, or an empty string otherwise (1.11.0)
The PROXY protocol must be previously enabled by setting the
proxy_protocol
parameter in the listen directive. -
same as
$args
- an absolute pathname corresponding to the root or alias directive’s value for the current request, with all symbolic links resolved to real paths
- client address
- client port
- user name supplied with the Basic authentication
- full original request line
-
request body
The variable’s value is made available in locations processed by the proxy_pass, fastcgi_pass,uwsgi_pass, and scgi_pass directives when the request body was read to a memory buffer.
-
name of a temporary file with the request body
At the end of processing, the file needs to be removed. To always write the request body to a file,client_body_in_file_only needs to be enabled. When the name of a temporary file is passed in a proxied request or in a request to a FastCGI/uwsgi/SCGI server, passing the request body should be disabled by the proxy_pass_request_body off, fastcgi_pass_request_body off,uwsgi_pass_request_body off, or scgi_pass_request_body off directives, respectively.
-
“
OK
” if a request has completed, or an empty string otherwise - file path for the current request, based on the root or alias directives, and the request URI
- unique request identifier generated from 16 random bytes, in hexadecimal (1.11.0)
- request length (including request line, header, and request body) (1.3.12, 1.2.7)
-
request method, usually “
GET
” or “POST
” - request processing time in seconds with a milliseconds resolution (1.3.9, 1.2.6); time elapsed since the first bytes were read from the client
- full original request URI (with arguments)
-
request scheme, “
http
” or “https
” - arbitrary response header field; the last part of a variable name is the field name converted to lower case with dashes replaced by underscores
- arbitrary field sent at the end of the response (1.13.2); the last part of a variable name is the field name converted to lower case with dashes replaced by underscores
-
an address of the server which accepted a request
Computing a value of this variable usually requires one system call. To avoid a system call, the listendirectives must specify addresses and use the
bind
parameter. - name of the server which accepted a request
- port of the server which accepted a request
-
request protocol, usually “
HTTP/1.0
”, “HTTP/1.1
”, or “ HTTP/2.0” - response status (1.3.2, 1.2.2)
-
information about the client TCP connection; available on systems that support the
TCP_INFO
socket option - local time in the ISO 8601 standard format (1.3.12, 1.2.7)
- local time in the Common Log Format (1.3.12, 1.2.7)
-
current URI in request,
normalized
The value of
$uri
may change during request processing, e.g. when doing internal redirects, or when using index files.
$arg_
name
$args
$binary_remote_addr
$body_bytes_sent
$bytes_sent
$connection
$connection_requests
$content_length
$content_type
$cookie_
name
$document_root
$document_uri
$host
$hostname
$http_
name
$https
$is_args
$limit_rate
$msec
$nginx_version
$pid
$pipe
$proxy_protocol_addr
$proxy_protocol_port
$query_string
$realpath_root
$remote_addr
$remote_port
$remote_user
$request
$request_body
$request_body_file
$request_completion
$request_filename
$request_id
$request_length
$request_method
$request_time
$request_uri
$scheme
$sent_http_
name
$sent_trailer_
name
$server_addr
$server_name
$server_port
$server_protocol
$status
$tcpinfo_rtt
,
$tcpinfo_rttvar
,
$tcpinfo_snd_cwnd
,
$tcpinfo_rcv_space
$time_iso8601
$time_local
$uri