Original: http://www.cnphp.info/nginx-embedded-variables-lasted-version.html
When configuring a website based on an nginx server, nginx built-in variables are bound to be used. Below, the author organizes it into a list and lists the variables of the latest version to facilitate the query during configuration.
nginx built-in variables
The built-in variables are stored in the ngx_http_core_module module, and the naming method of the variables is consistent with the apache server variables. Collectively, these variables represent the content of client request headers, such as $http_user_agent, $http_cookie, etc. Below are all built-in variables supported by nginx:
$arg_name
The parameter name in the request, that is, arg_name in the form of arg_name=arg_value after "?"
$args
parameter value in the request
$binary_remote_addr
The binary form of the client address, fixed length is 4 bytes
$body_bytes_sent
The number of bytes to transmit to the client, excluding response headers; this variable is compatible with the "%B" parameter in Apache's mod_log_config module
$bytes_sent
Bytes transferred to client (1.3.8, 1.2.5)
$connection
Sequence number of the TCP connection (1.3.8, 1.2.5)
$connection_requests
Current number of requests for TCP connections (1.3.8, 1.2.5)
$content_length
"Content-Length" request header field
$content_type
"Content-Type" request header field
$cookie_name
cookie name
$document_root
The document root or alias for the current request
$document_uri
Same $ uri
$host
The priority is as follows: hostname of the HTTP request line > "HOST" request header field > server name matching the request
$hostname
CPU name
$http_name
Match any request header field; the second half of "name" in the variable name can be replaced with any request header field. For example, if you need to obtain the http request header: "Accept-Language" in the configuration file, then replace "-" with an underscore, Replace uppercase letters with lowercase, such as: $http_accept_language.
$https
The value is "on" if SSL security mode is enabled, otherwise an empty string.
$is_args
The value is "?" if there is a parameter in the request, otherwise an empty string.
$limit_rate
Used to set the speed limit of the response, see limit_rate for details.
$msec
Current Unix timestamp (1.3.9, 1.2.6)
$nginx_version
nginx version
$pid
PID of the worker process
$pipe
"p" if the request came from piped communication, otherwise "." (1.3.12, 1.2.7)
$proxy_protocol_addr
Get the client address of the proxy access server. If it is direct access, the value is an empty string. (1.5.12)
$query_string
same as $args
$realpath_root
The real path to the current request's document root or alias, with all symbolic links converted to real paths.
$remote_addr
client address
$remote_port
client port
$remote_user
Username for HTTP Basic Authentication Service
$request
Represents the request address of the client
$request_body
Client's request body
This variable can be used in location to pass the request body to the next-level proxy server through proxy_pass, fastcgi_pass, uwsgi_pass, and scgi_pass.
$request_body_file
Save the client request body in a temporary file. After file processing is complete, the file needs to be deleted. If you need to enable this function, you need to set client_body_in_file_only. If you pass the secondary file to the backend proxy server, you need to disable the request body, that is, set proxy_pass_request_body off, fastcgi_pass_request_body off, uwsgi_pass_request_body off, or scgi_pass_request_body off.
$request_completion
The value is "OK" if the request was successful, or null if the request was not completed or the request was not the last part of a range request.
$request_filename
The file path of the current connection request, generated by the root or alias directive and the URI request.
$request_length
The length of the request (including the requested address, http request headers and request body) (1.3.12, 1.2.7)
$request_method
HTTP request method, usually "GET" or "POST"
$request_time
Time used to process client requests (1.3.9, 1.2.6); timed from reading the first byte of the client.
$request_uri
This variable is equal to the original URI containing some client request parameters, it cannot be modified, please see $uri to change or rewrite the URI without the hostname, for example: "/cnphp/test.php?arg=freemouse".
$scheme
The web protocol used by the request, "http" or "https"
$sent_http_name
Any HTTP response header field can be set; the second half "name" in the variable name can be replaced with any response header field. If you need to set the response header Content-length, then replace "-" with underscore, uppercase letters with lowercase, The form is: $sent_http_content_length 4096.
$server_addr
Server-side address, it should be noted that in order to avoid accessing the Linux system kernel, the ip address should be set in the configuration file in advance.
$server_name
Server name, www.cnphp.info
$server_port
server port
$server_protocol
The HTTP version of the server, usually "HTTP/1.0" or "HTTP/1.1"
$status
HTTP response codes (1.3.2, 1.2.2)
$tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, $tcpinfo_rcv_space
Client TCP connection specific information
$time_iso8601
ISO 8610 format for server time (1.3.12, 1.2.7)
$time_local
Server time in LOG Format (1.3.12, 1.2.7)
$uri
The current URI in the request (without request parameters, the parameters are located in $args), which can be different from the value of $request_uri passed by the browser. It can be modified by internal redirection, or by using the index directive. $uri does not contain the hostname, Such as "/foo/bar.html".