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. Alsothereareothervariables:
$arg_name
argument name inthe request line
$args
arguments inthe request line
$binary_remote_addr
client address ina binary form, value’s length is always 4bytesfor IPv4 addresses or16bytesfor IPv6 addresses
$body_bytes_sent
numberofbytes sent toa client, not counting the response header; this variable is compatible withthe “%B” parameter ofthe mod_log_config Apache module
$bytes_sent
numberofbytes sent toa client (1.3.8, 1.2.5)
$connection
connection serial number (1.3.8, 1.2.5)
$connection_requests
current numberof requests made through a connection (1.3.8, 1.2.5)
$content_length
“Content-Length” request header field
$content_type
“Content-Type” request header field
$cookie_name
the name cookie
$document_root
root oralias directive’s valueforthe current request
$document_uri
same as $uri
$host
in this order of precedence: host name fromthe request line, or host name fromthe “Host” request header field, orthe server name matching a request
$hostname
host name
$http_name
arbitrary request header field; thelast part ofavariable name is the field name converted tolowercasewith dashes replaced by underscores
$https
“on” ifconnectionoperatesinSSLmode, oranemptystringotherwise
$is_args
“?” ifa request line has arguments, oranemptystring otherwise
$limit_rate
setting this variable enables response rate limiting; see limit_rate
$msec
current timeinsecondswiththemilliseconds resolution (1.3.9, 1.2.6)
$nginx_version
nginx version
$pid
PID ofthe worker process
$pipe
“p” if request was pipelined, “.” otherwise (1.3.12, 1.2.7)
$proxy_protocol_addr
client address fromthe PROXY protocol header, oranemptystring otherwise (1.5.12)
The PROXY protocol must be previously enabled by setting the proxy_protocol parameter inthe listen directive.
$proxy_protocol_port
client port fromthe PROXY protocol header, oranemptystring otherwise (1.11.0)
The PROXY protocol must be previously enabled by setting the proxy_protocol parameter inthe listen directive.
$query_string
same as $args
$realpath_root
an absolute pathname corresponding tothe root oralias directive’s valueforthe current request, with all symbolic links resolved to real paths
$remote_addr
client address
$remote_port
client port
$remote_user
user name supplied withthe Basic authentication
$request
full original request line
$request_body
request body
The variable’s value is made available in locations processed bythe proxy_pass, fastcgi_pass, uwsgi_pass, and scgi_pass directives when the request body was readtoa memory buffer.
$request_body_file
name ofa temporary filewiththe request body
At theendofprocessing, thefileneedstoberemoved. Toalwayswritetherequestbodytoafile, client_body_in_file_onlyneedstobeenabled. WhenthenameofatemporaryfileispassedinaproxiedrequestorinarequesttoaFastCGI/uwsgi/SCGIserver, passingtherequestbodyshouldbedisabledbytheproxy_pass_request_bodyoff, fastcgi_pass_request_bodyoff, uwsgi_pass_request_bodyoff, orscgi_pass_request_bodyoffdirectives, respectively.
$request_completion
“OK” ifa request has completed, oranemptystring otherwise
$request_filename
file path forthe current request, based ontherootoraliasdirectives, andtherequestURI
$request_id
unique request identifier generated from16randombytes, in hexadecimal (1.11.0)
$request_length
request length (including request line, header, and request body) (1.3.12, 1.2.7)
$request_method
request method, usually “GET” or “POST”
$request_time
request processing timeinsecondswithamilliseconds resolution (1.3.9, 1.2.6); time elapsed since thefirstbytes were readfromthe client
$request_uri
full original request URI (with arguments)
$scheme
request scheme, “http” or “https”
$sent_http_name
arbitrary response header field; thelast part ofavariable name is the field name converted tolowercasewith dashes replaced by underscores
$server_addr
an address ofthe server which accepted a request
Computing avalueof this variable usually requires onesystem call. To avoid asystem call, the listen directives must specify addresses and use the bind parameter.
$server_name
name ofthe server which accepted a request
$server_port
port ofthe server which accepted a request
$server_protocol
request protocol, usually “HTTP/1.0”, “HTTP/1.1”, or “HTTP/2.0”
$status
response status (1.3.2, 1.2.2)
$tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, $tcpinfo_rcv_space
information about the client TCP connection; available onsystemsthatsupporttheTCP_INFOsocketoption
$time_iso8601
localtimeinthe ISO 8601 standard format (1.3.12, 1.2.7)
$time_local
localtimeinthe Common Log Format (1.3.12, 1.2.7)
$uri
current URI in request, normalized
The valueof $uri may change during request processing, e.g. when doing internal redirects, or when using index files.
nginx log_format 变量含义详解Embedded VariablesThe ngx_http_core_module module supports embedded variables with names matching the Apache Server variables. First of all, these are variables representing clie