NGINX Variables

195 — Searchable variable reference across core HTTP, stream, and third-party modules — with examples and gotchas.

NGINX Core (HTTP)124

$arg_* The variable $arg_ retrieves the value of a specific query parameter from the request URI. $args The $args variable contains the query string arguments of the request, excluding the '?' character. $binary_remote_addr The $binary_remote_addr variable contains the binary representation of the client's IP address. Cacheable $body_bytes_sent The $body_bytes_sent variable in NGINX contains the number of bytes sent to the client in the response body, excluding the response headers. Cacheable $bytes_sent The $bytes_sent variable contains the total number of bytes sent to the client in response to a request. Cacheable $connection The $connection variable returns the connection descriptor number for the current request in NGINX. Cacheable $connection_requests The $connection_requests variable returns the number of requests received on the current connection. Cacheable $connection_time The $connection_time variable returns the time taken to establish a connection to the client, in seconds. $content_length The variable $content_length contains the value of the 'Content-Length' HTTP header sent by the client, representing the size of the request body in bytes. Cacheable $content_type The $content_type variable in NGINX holds the value of the Content-Type header of the HTTP response. Cacheable $cookie_* The $cookie_ variable prefix is used to access the value of HTTP cookies sent by the client. Cacheable $document_root The $document_root variable returns the root directory of the current server or location block as defined in the NGINX configuration. $document_uri The $document_uri variable contains the URI of the request without any query string and with decoded percent-encoded characters. $fastcgi_path_info The variable $fastcgi_path_info contains the extra path information that follows the script name in a FastCGI request. $fastcgi_script_name The $fastcgi_script_name variable contains the script name being processed by the FastCGI server. $grpc_internal_trailers The variable $grpc_internal_trailers contains the internal trailer fields of a gRPC response. $gzip_ratio The $gzip_ratio variable holds the compression ratio achieved by gzip when NGINX serves a compressed response. Cacheable $host The $host variable in NGINX holds the host name from the HTTP request header or the server name defined in the configuration. Cacheable $hostname The $hostname variable returns the hostname of the server as specified in the server block. Cacheable $http_* The variable $http_ holds the value of a specific HTTP header from the client request, prefixed by 'http_'. Cacheable $http_cookie The $http_cookie variable captures the value of the Cookie header from an incoming HTTP request. Cacheable $http_host The `$http_host` variable contains the value of the Host header sent by the client in the HTTP request. Cacheable $http_referer The $http_referer variable contains the value of the Referer HTTP header from the client's request. Cacheable $http_user_agent The $http_user_agent variable contains the value of the User-Agent HTTP request header sent by the client. Cacheable $http_via The $http_via variable retrieves the value of the 'via' header sent by upstream proxies in HTTP requests. Cacheable $http_x_forwarded_for The $http_x_forwarded_for variable contains the value of the X-Forwarded-For header from the client request, which indicates the originating IP address of the client making the request. Cacheable $https The $https variable indicates whether a request was made over HTTPS (secure) or not. Cacheable $invalid_referer The $invalid_referer variable is set to 1 if the request's referer is not allowed, based on specified access rules. Cacheable $is_args The $is_args variable indicates whether the current request includes arguments in its query string. $is_request_port The $is_request_port variable indicates whether the request was made on an alternate port rather than the default port for the protocol. Cacheable $limit_conn_status $limit_conn_status returns the status of connection limiting on a per-client basis in NGINX. $limit_rate $limit_rate controls the maximum transfer rate for a response, effectively throttling bandwidth usage per connection. $limit_req_status The $limit_req_status variable outputs the status code of the request limiting mechanism in NGINX. $msec The $msec variable contains the current time in milliseconds since the epoch. $nginx_version The variable $nginx_version holds the version number of the currently running NGINX instance. Cacheable $pid The $pid variable returns the process ID (PID) of the NGINX worker process handling the current request. Cacheable $pipe The $pipe variable indicates whether the request is being processed in a pipelined fashion. Cacheable $proxy_add_via The $proxy_add_via variable is used to append a 'Via' header to HTTP requests being proxied in NGINX. Cacheable $proxy_add_x_forwarded_for The $proxy_add_x_forwarded_for variable appends the client's IP address to the X-Forwarded-For header in a proxy setup. Cacheable $proxy_host The variable $proxy_host contains the hostname of the upstream server being proxied to. $proxy_internal_body_length $proxy_internal_body_length returns the length of the request body received from a proxied server internally. $proxy_internal_chunked $proxy_internal_chunked indicates whether internal responses should be sent in chunked transfer encoding. $proxy_internal_connection $proxy_internal_connection indicates whether the connection to a proxied server is used internally or externally. $proxy_internal_host $proxy_internal_host returns the hostname of the internal proxy for a request. $proxy_port The $proxy_port variable returns the port number of the proxied server. $proxy_protocol_addr $proxy_protocol_addr returns the client address from the PROXY protocol, if enabled. Cacheable $proxy_protocol_port The $proxy_protocol_port variable returns the port number from which a proxied request is received when using the PROXY protocol. Cacheable $proxy_protocol_server_addr $proxy_protocol_server_addr returns the IP address of the client as sent by the proxy protocol when enabled in NGINX. Cacheable $proxy_protocol_server_port The $proxy_protocol_server_port variable returns the server port as specified in the PROXY protocol. Cacheable $proxy_protocol_tlv_* The $proxy_protocol_tlv_ variables provide access to information contained in the Proxy Protocol TLV (Type-Length-Value) format. Cacheable $query_string The $query_string variable contains the query string part of the client's request URI, excluding the leading '?'. $realip_remote_addr The variable $realip_remote_addr contains the original client IP address when the NGINX server is used behind a proxy or load balancer. Cacheable $realip_remote_port The variable $realip_remote_port holds the port number of the client making the request, as it is received by NGINX from the upstream server. Cacheable $realpath_root The $realpath_root variable returns the canonical filename of the root directory of a location block, resolving any symbolic links. $remote_addr The $remote_addr variable holds the IP address of the client making the request to the NGINX server. Cacheable $remote_port The $remote_port variable in NGINX contains the port number of the client making the request, used in access control and logging. Cacheable $remote_user The $remote_user variable contains the username supplied by the client during HTTP Basic Authentication. Cacheable $request The $request variable contains the full request line received from the client, including the HTTP method, URI, and HTTP version. Cacheable $request_body The $request_body variable contains the raw body of the client request. Cacheable $request_body_file The $request_body_file variable contains the path to a temporary file holding the request body when the body is too large to fit in memory. Cacheable $request_completion The variable $request_completion returns the status of the request processing, indicating whether the request was completed successfully or not. Cacheable $request_filename The $request_filename variable contains the full path to the file being requested by the client. $request_id The $request_id variable contains a unique identifier for each request processed by NGINX. Cacheable $request_length The variable $request_length returns the total size of the client request body in bytes. $request_method The $request_method variable in NGINX contains the HTTP method used for the current request. $request_port The $request_port variable contains the port number used by the client to send the request to the server. Cacheable $request_time $request_time contains the total time taken to process the request, in seconds with millisecond precision. $request_uri The $request_uri variable contains the original request URI as sent by the client, including the query string if present. Cacheable $scheme The $scheme variable in NGINX returns the protocol of the current request (HTTP or HTTPS). Cacheable $secure_link The $secure_link variable is used to validate a secure link to a resource based on a hashed token. Cacheable $secure_link_expires $secure_link_expires returns the expiration timestamp for a secure link in NGINX. Cacheable $sent_http_* The $sent_http_ prefix variable returns HTTP response headers sent to the client. Cacheable $sent_http_cache_control $sent_http_cache_control contains the value of the 'Cache-Control' header sent in the HTTP response. Cacheable $sent_http_connection The variable $sent_http_connection holds the value of the 'Connection' header sent to the client in a HTTP response. Cacheable $sent_http_content_length The $sent_http_content_length variable returns the value of the Content-Length header sent in the HTTP response. Cacheable $sent_http_content_type The $sent_http_content_type variable holds the Content-Type header sent in the HTTP response from NGINX. Cacheable $sent_http_keep_alive The $sent_http_keep_alive variable in NGINX contains the value of the 'Keep-Alive' header sent to the client in the response. Cacheable $sent_http_last_modified The $sent_http_last_modified variable contains the Last-Modified header returned by the server in the response to the client. Cacheable $sent_http_link The $sent_http_link variable contains the value of the Link HTTP response header sent by NGINX. Cacheable $sent_http_location The $sent_http_location variable contains the HTTP Location header sent in the response when an internal redirection occurs. Cacheable $sent_http_transfer_encoding $sent_http_transfer_encoding contains the value of the 'Transfer-Encoding' header sent to the client. Cacheable $sent_trailer_* The $sent_trailer_ variable is a prefix variable used to retrieve trailers sent with HTTP responses in NGINX. Cacheable $server_addr The $server_addr variable returns the IP address of the server as specified in the NGINX configuration. Cacheable $server_name The $server_name variable represents the name of the virtual host serving the request. Cacheable $server_port The $server_port variable returns the port number on which the current request was received. Cacheable $server_protocol The $server_protocol variable contains the protocol used for the current request, typically HTTP or HTTPS. Cacheable $ssl_alpn_protocol The variable $ssl_alpn_protocol contains the Application-Layer Protocol Negotiation (ALPN) protocol selected during the TLS handshake. Cacheable $ssl_cipher The $ssl_cipher variable contains the name of the cipher used for SSL/TLS connections. Cacheable $ssl_ciphers The $ssl_ciphers variable contains the list of SSL/TLS ciphers used for the current connection. Cacheable $ssl_client_cert The variable $ssl_client_cert contains the client's SSL certificate as a PEM encoded string when SSL client verification is enabled. Cacheable $ssl_client_escaped_cert The $ssl_client_escaped_cert variable contains the PEM-encoded and URL-escaped client certificate sent by the client during SSL handshake. Cacheable $ssl_client_fingerprint The variable $ssl_client_fingerprint represents the fingerprint of the client's SSL certificate. Cacheable $ssl_client_i_dn The $ssl_client_i_dn variable holds the Identity Distinguished Name (DN) of a client during SSL/TLS sessions. Cacheable $ssl_client_i_dn_legacy The $ssl_client_i_dn_legacy variable returns the legacy distinguished name (DN) string representation of the client's SSL certificate. Cacheable $ssl_client_raw_cert The $ssl_client_raw_cert variable contains the raw bytes of the client's SSL certificate. Cacheable $ssl_client_s_dn The $ssl_client_s_dn variable contains the subject distinguished name from the client's SSL certificate. Cacheable $ssl_client_s_dn_legacy The $ssl_client_s_dn_legacy variable contains the legacy subject distinguished name (DN) of the SSL client certificate. Cacheable $ssl_client_serial The $ssl_client_serial variable contains the serial number of the client SSL certificate used in a secured connection. Cacheable $ssl_client_sigalg The variable $ssl_client_sigalg contains the signature algorithm used by the client's SSL certificate. Cacheable $ssl_client_v_end The variable $ssl_client_v_end contains the end time of the client's SSL connection in seconds since the epoch. Cacheable $ssl_client_v_remain $ssl_client_v_remain returns the remaining number of bytes in the SSL client's certificate chain after the current certificate. Cacheable $ssl_client_v_start $ssl_client_v_start returns the timestamp when the SSL handshake is completed and the client connection is established. Cacheable $ssl_client_verify $ssl_client_verify indicates the verification status of a client certificate in SSL connections. Cacheable $ssl_curve The $ssl_curve variable returns the name of the elliptic curve used for SSL/TLS connections. Cacheable $ssl_curves The $ssl_curves variable returns the list of elliptic curves negotiated during the SSL handshake. Cacheable $ssl_early_data The $ssl_early_data variable indicates whether early data has been received in an SSL/TLS connection. $ssl_ech_outer_server_name $ssl_ech_outer_server_name returns the outer server name used in the Encrypted ClientHello for the current SSL connection. Cacheable $ssl_ech_status The $ssl_ech_status variable indicates the status of the Encrypted ClientHello (ECH) support for the current SSL connection. Cacheable $ssl_protocol $ssl_protocol contains the SSL/TLS protocol version used for a connection. Cacheable $ssl_server_name The variable $ssl_server_name contains the name of the server specified with the 'server_name' directive that matches a request during SSL handshake. Cacheable $ssl_session_id The $ssl_session_id variable contains the unique identifier for the current SSL session on an NGINX server. Cacheable $ssl_session_reused The $ssl_session_reused variable indicates whether an existing SSL session was reused for the current connection. Cacheable $ssl_sigalg The $ssl_sigalg variable returns the signature algorithm used in the SSL handshake of a secure connection. Cacheable $status The $status variable returns the HTTP response status code of the current request being processed by NGINX. $tcpinfo_rcv_space The $tcpinfo_rcv_space variable returns the amount of memory allocated for the incoming TCP buffer space. $tcpinfo_rtt The $tcpinfo_rtt variable returns the round-trip time (RTT) of the TCP connection in microseconds. $tcpinfo_rttvar The $tcpinfo_rttvar variable returns the round-trip time variation for TCP connections in microseconds. $tcpinfo_snd_cwnd $tcpinfo_snd_cwnd returns the TCP send congestion window size in bytes. $time_iso8601 The variable $time_iso8601 returns the current time in ISO 8601 format. $time_local The $time_local variable returns the current local time in the format used by the Common Log Format. $uid_got The $uid_got variable returns the user ID of the request's owner, which is useful for access control and logging. Cacheable $uid_reset The $uid_reset variable indicates whether the UID of a request should be reset based on access control rules. Cacheable $uid_set The $uid_set variable contains the user ID set for the current request context in NGINX. Cacheable $uri The $uri variable in NGINX returns the URI part of a requested resource without the domain or protocol information.

NGINX Core (Stream)3

NGINX CoolKit Module2

NGINX Module for Google Mirror creation4

An NGINX module for collecting stats into Graphite1

IP address anonymizer module for NGINX3

NGINX JWT Module4

Kaltura Media Framework Common NGINX Module15

NGINX module for handling file uploads16

Nginx stream server traffic status core module9

Secure token module for NGINX4

NGINX sysguard module10