Watch: Variables and explanations provided by Nginx HTTP kernel modules

Guide When the ngx_http_core_module module processes a request, there will be a large number of variables. These variables can be recorded through the access log. Can be used for other nginx modules.

Detailed description: Variables provided by nginx http kernel module and explanation details: Variables provided by nginx http kernel module And explanation

We will use some variables in our request strategy, such as rewriting, etc., by the way The variables provided by the ngx_http_core_module module are summarized as follows:

Parameter name annotation
The value of a parameter in the $arg_PARAMETER HTTP request, such as / index.php?site=www.ttlsa.com, you can use $arg_site to get the value of www.ttlsa.com.


$args The complete parameters in the HTTP request. For example, in the request /index.php?width=400&height=200, $args represents the string width=400&height=200.

$binary_remote_addr Client address in binary format. For example: Ă B

$body_bytes_sent represents the number of bytes in the body part of the http response sent to the client

$content_length represents the Content-Length field in the client request header

$content_type represents the Content-Type field in the client request header

$cookie_COOKIE represents the cookie field in the client request header

$document_root represents the value of the root configuration item used by the current request

$uri represents the URI of the current request without any parameters

$document_uri has the same meaning as $uri

$request_uri represents the original request URI sent by the client, with complete parameters.

$uri and $document_uri may not be the original request of the user. They may be the redirected URI after internal redirection, and $request_uri will never change, it is always the original URI of the client.

$host represents the Host field in the client request header. If the Host field does not exist, replace it with the actual server (virtual host) name. If there is a port in the Host field, such as IP:PORT, then $host removes the port and its value is IP.

$host is all lowercase. These features are different from http_host in http_HEADER, http_host only takes out the value corresponding to the Host header.

$hostname represents the name of the machine where Nginx is located, which is the same as the value returned by the gethostbyname call

$http_HEADER represents the value of the corresponding header in the current HTTP request. The HEADER name is all lowercase. For example, to show the value corresponding to the Host header in the request, use the $http_host table

$sent_http_HEADER represents the value of the corresponding header in the HTTP response returned to the client. The HEADER name is all lowercase. For example, use $sent_ http_content_type to represent the value corresponding to the Content-Type header in the response

$is_args indicates whether the URI in the request takes parameters, if it takes parameters, the value of $is_args is ?, if it does not take parameters, it is an empty string

$limit_rate indicates the rate limit of the current connection, 0 indicates unlimited rate

$nginx_version represents the current Nginx version number

$query_string The parameters in the request URI are the same as $args, but $query_string is read-only and will not change

$remote_addr represents the address of the client

$remote_port represents the port used by the client to connect

$remote_user represents the user name defined when using the Auth Basic Module

$request_filename represents the file path of the URI in the user request after root or alias conversion

$request_body represents the body of the HTTP request, this parameter is only meaningful in proxy_pass or fastcgi_pass

$request_body_file represents the temporary file name stored in the body of the HTTP request

$request_completion When the request has been fully completed, its value is "ok". If it is not completed, it is necessary to return to the client, and its value is an empty string; or in the case of resumable transmission, if the HTTP range is not used to access the last piece of the file, then its value is also an empty string.

$request_method represents the method name of the HTTP request, such as GET, PUT, POST, etc.

$scheme means HTTP scheme, such as https://nginx.com/ in the request

$server_addr represents the server address

$server_name represents the server name

$server_port represents the server port

$server_protocol represents the protocol used by the server to send a response to the client, such as HTTP/1.1 or HTTP/1.0

Parameter name comment

Leave a Comment

Your email address will not be published.