Skip to content

Instantly share code, notes, and snippets.

@geordee
Forked from magnetikonline/README.md
Created August 25, 2018 05:06
Show Gist options
  • Save geordee/4d2a2bc441f9e903a6d0156878f4cf93 to your computer and use it in GitHub Desktop.
Save geordee/4d2a2bc441f9e903a6d0156878f4cf93 to your computer and use it in GitHub Desktop.
Nginx embedded variables.

Nginx embedded variables

Source document at: http://nginx.org/en/docs/http/ngx_http_core_module.html#variables

Wiki document (deprecated) at: http://wiki.nginx.org/HttpCoreModule

Name Description Read only
$arg_name Argument name in the request line No
$args Arguments in the request line No
$binary_remote_addr Client address in a binary form, value’s length is always 4 bytes for IPv4 addresses or 16 bytes for IPv6 addresses
$body_bytes_sent Number of bytes sent to a client, not counting the response header; this variable is compatible with the "%B" parameter of the mod_log_config Apache module
$bytes_sent Number of bytes sent to a client (1.3.8, 1.2.5)
$connection Connection serial number (1.3.8, 1.2.5)
$connection_requests Current number of 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 or alias directive's value for the current request
$document_uri Same as $uri
$host 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
$hostname Host name
$http_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
$https "on" if connection operates in SSL mode, or an empty string otherwise
$is_args "?" if a request line has arguments, or an empty string otherwise
$limit_rate Setting this variable enables response rate limiting; see limit_rate
$msec Current time in seconds with the milliseconds resolution (1.3.9, 1.2.6)
$nginx_version Nginx version
$pid PID of the worker process
$pipe "p" if request was pipelined, "." otherwise (1.3.12, 1.2.7)
$proxy_protocol_addr 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.
$proxy_protocol_port 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.
$query_string Same as $args Yes
$realpath_root An absolute pathname corresponding to the root or alias directive's value for the current request, with all symbolic links resolved to real paths
$remote_addr Client address
$remote_port Client port
$remote_user User name supplied with the Basic authentication
$request Full original request line Yes
$request_body 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.
$request_body_file 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 server, passing the request body should be disabled by the proxy_pass_request_body off and fastcgi_pass_request_body off directives, respectively.
$request_completion "OK" if a request has completed, or an empty string otherwise
$request_filename File path for the current request, based on the root or alias directives, and the request URI
$request_id Unique request identifier generated from 16 random bytes, 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 time in seconds with a milliseconds resolution (1.3.9, 1.2.6); time elapsed since the first bytes were read from the client
$request_uri Full original request URI (with arguments) Yes
$scheme Request scheme, "http" or "https"
$sent_http_name Arbitrary response header field; the last part of a variable name is the field name converted to lower case with dashes replaced by underscores
$sent_trailer_name 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
$server_addr 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 listen directives must specify addresses and use the bind parameter.
$server_name Name of the server which accepted a request
$server_port Port of the server which accepted a request
$server_protocol Request protocol, usually "HTTP/1.0" or "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 on systems that support the TCP_INFO socket option
$time_iso8601 Local time in the ISO 8601 standard format (1.3.12, 1.2.7)
$time_local Local time in the Common Log Format (1.3.12, 1.2.7)
$uri 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment