A collection of extra variables for NGINX. Used to meet logging or other needs.
Some of these variables need to come from nginx core patch nginx-ext.patch to work. These variables will be marked with * in the following text.
Original request path (without arguments).
Original request arguments.
“?” if original request uri has arguments, or an empty string otherwise.
"&" if original request uri has arguments, or "?" otherwise.
Full current uri (with arguments), normalized.
The value of $current_uri may change during request processing, e.g. when doing internal redirects, or when using index files.
Current path (without arguments), normalized.
The value of $current_path is the same as $uri. it may change during request processing, e.g. when doing internal redirects, or when using index files.
Full current uri in request (with arguments), normalized and escaped again.
The value of $escaped_current_uri may change during request processing, e.g. when doing internal redirects, or when using index files.
Current path in request (without arguments), normalized and escaped again.
The value of $normalized_current_uri_path may change during request processing, e.g. when doing internal redirects, or when using index files.
"&" if a request line has arguments, or "?" otherwise.
A literal dollar sign.
Current time in seconds.
The extension from $uri.
"1" if the current request is an "internal request", i.e., a request initiated from inside the current Nginx server instead of from the client side, or "0" otherwise.
"1" if the current request is an Nginx subrequest, or "0" otherwise.
The number of times the current request has been internally.
The number of subrequests performed for this request.
Connection established timestamp in seconds with the milliseconds resolution.
Request created timestamp in seconds with the milliseconds resolution.
Response header sent timestamp in seconds with the milliseconds resolution.
Keeps time spent on handling request internally from receiving the request to sending the response header to the client.
Keeps time spent on sending the response body to the client.
Uppercase host name.
Lowercase host name.
Local time in the rfc 1123 standard format. the time format is consistent with the http Date
header.
Upstream method, usually “GET” or “POST”.
Upstream scheme, "http" or "https".
Full upstream request uri.
Keeps the IP address and port, or the path to the UNIX-domain socket of the latest upstream server.
Keeps status code of the response obtained from the latest upstream server.
Keeps timestamp of upstream starts; the time is kept in seconds with millisecond resolution. Times of several responses are separated by commas and colons like addresses in the $upstream_addr variable.
Keeps timestamp of latest upstream starts; the time is kept in seconds with millisecond resolution.
Keeps timestamp of upstream ssl handshake starts; the time is kept in seconds with millisecond resolution. Times of several responses are separated by commas and colons like addresses in the $upstream_addr variable.
Keeps timestamp of latest upstream ssl handshake starts; the time is kept in seconds with millisecond resolution.
Keeps timestamp of upstream request send starts; the time is kept in seconds with millisecond resolution. Times of several responses are separated by commas and colons like addresses in the $upstream_addr variable.
Keeps timestamp of latest upstream request send starts; the time is kept in seconds with millisecond resolution.
Keeps timestamp of upstream request send ends; the time is kept in seconds with millisecond resolution. Times of several responses are separated by commas and colons like addresses in the $upstream_addr variable.
Keeps timestamp of latest upstream request send ends; the time is kept in seconds with millisecond resolution.
Keeps timestamp of upstream response header sent; the time is kept in seconds with millisecond resolution. Times of several responses are separated by commas and colons like addresses in the $upstream_addr variable.
Keeps timestamp of latest upstream response header sent; the time is kept in seconds with millisecond resolution.
Keeps timestamp of upstream response sent or abnormal interruption; the time is kept in seconds with millisecond resolution. Times of several responses are separated by commas and colons like addresses in the $upstream_addr variable.
Keeps timestamp of latest upstream response sent or abnormal interruption; the time is kept in seconds with millisecond resolution.
Keeps time spent on establishing a connection with the upstream server; the time is kept in seconds with millisecond resolution. In case of SSL, includes time spent on handshake.
Keeps time spent on establishing a connection with the upstream server; the time is kept in seconds with millisecond resolution. In case of SSL, does not include time spent on handshake. Times of several connections are separated by commas and colons like addresses in the $upstream_addr variable.
Keeps time spent on establishing a connection with the upstream server; the time is kept in seconds with millisecond resolution. In case of SSL, does not include time spent on handshake.
Keeps time spent on upstream ssl handshake; the time is kept in seconds with millisecond resolution. Note that this timing starts only after receiving the upstream request header. Times of several ssl connections are separated by commas and colons like addresses in the $upstream_addr variable.
Keeps time spent on latest upstream ssl handshake; the time is kept in seconds with millisecond resolution. Note that this timing starts only after receiving the upstream request header.
Keeps time spent on sending request to the upstream server; the time is kept in seconds with millisecond resolution. Times of several send requests are separated by commas and colons like addresses in the $upstream_addr variable.
Keeps time spent on sending request to the latest upstream server; the time is kept in seconds with millisecond resolution.
Keeps time spent on reading response from the upstream server; the time is kept in seconds with millisecond resolution. Note that this timing starts only after receiving the upstream request header. Times of several responses are separated by commas and colons like addresses in the $upstream_addr variable.
Keeps time spent on reading response from the latest upstream server; the time is kept in seconds with millisecond resolution. Note that this timing starts only after receiving the upstream request header.
Keeps time spent on receiving the response header from the latest upstream server; the time is kept in seconds with millisecond resolution.
Keeps time spent on receiving the response from the latest upstream server; the time is kept in seconds with millisecond resolution.
Keeps the length of the response obtained from the upstream server; the length is kept in bytes.
Number of bytes received from an upstream server.
Number of bytes sent to an upstream server.
"1" if the upstream request is cacheable, or "0" otherwise. it will be empty when the upstream request has not yet been established, do not use it in the early phase of the request (such as the rewrite or access phase).
The cache key being used.
The crc32 checksum of cache key.
The md5sum hash of cache key.
The md5sum hash of main cache key.
The md5sum hash of variant cache key when a request is cached based on the Vary response header.
The file path of upstream cache.
Age of the cache item.
Cache create time. unix time.
Cache create time. the time format is consistent with the http Date
header.
Cache expire time. unix time.
Cache expire time. the time format is consistent with the http Date
header.
Cache ttl.
Cache max age.
The following is some timestamp calculation logic. The variables calculated using $msec have accurate values only when used in the access logs. Their values may not be accurate if used outside the log phase.
-
$connection_time = $msec - $connection_established_msec (connections may be reused)
-
$request_handling_time = $response_header_sent_msec - $request_created_msec
-
$response_body_time = $msec - $response_header_sent_msec
-
$request_time = $msec - $request_created_msec
-
$upstream_last_transport_connect_time = $upstream_last_ssl_start_msec - $upstream_last_start_msec (with ssl)
-
$upstream_last_transport_connect_time = $upstream_last_send_start_msec - $upstream_last_start_msec (without ssl)
-
$upstream_last_ssl_time = $upstream_last_send_start_msec - $upstream_last_ssl_start_msec
-
$upstream_last_send_time = $upstream_last_send_end_msec - $upstream_last_send_start_msec
-
$upstream_last_read_time = $upstream_last_end_msec - $upstream_last_header_msec
-
$upstream_last_header_time = $upstream_last_header_msec - $upstream_last_start_msec
-
$upstream_last_response_time = $upstream_last_end_msec - $upstream_last_start_msec
Jonathan Kolb Hanada [email protected]
This Nginx module is licensed under BSD 2-Clause License.