Summary of global variables in Nginx
- 2020-05-06 12:14:10
- OfStack
Variables
The core module supports built-in variables, whose names correspond with the names of variables in Apache.
First of all, there are the variables, which represent the lines of the title of the client request, for example, $http_user_agent, $http_cookie, and so forth.
Furthermore, there are other variables:
Edit section: $arg_PARAMETER $arg_PARAMETER
This variable contains the value of the GET request variable PARAMETER if present in the query string
Edit section: $args $args
This variable is equal to arguments in the line of request;
Edit section: $binary_remote_addr $binary_remote_addr
The address of the client in binary form;
Edit section: $body_bytes_sent $body_bytes_sent
(undocumented)
Edit section: $content_length $content_length
This variable is equal to line Content-Length in the header of request;
Edit section: $content_type $content_type
This variable is equal to line Content-Type in the header of request;
Edit section: $cookie_COOKIE $cookie_COOKIE
The value of the cookie COOKIE;
Edit section: $document_root $document_root
This variable is equal to the value of directive root for the current request;
Edit section: $document_uri $document_uri
The same as $uri.
Edit section: $host $host
This variable is equal to line Host in the header of request or name of the server processing the request if the Host header is not available.
This variable may have a different value from $http_host when the Host input header is absent or has an empty value.
Edit section: $http_HEADER $http_HEADER
The value of HTTP HEADER when converted to of to and with 'dashes' underscores', e.g. $http_user_agent, $http_referer... ;
Edit section: $is_args $is_args
Evaluates to "?" if $args is set, "" otherwise
Edit section: $limit_rate $limit_rate
This variable allows limiting the connection rate.
Edit section: $query_string $query_string
The same as $args.
Edit section: $remote_addr $remote_addr
The address of the client.
Edit section: $remote_port $remote_port
The port of the client;
Edit section: $remote_user $remote_user
This variable is equal to the name of user, authenticated by the Auth Basic Module;
Edit section: $request_filename $request_filename
This variable is equal to path to the file for the current request, formed from directives root or alias and URI request;
Edit section: $request_body $request_body
This variable(0.7.58+) contains the body of the request. The significance of this variable appears in locations with directives proxy_pass or fastcgi_pass.
Edit section: $request_body_file $request_body_file
Client request body temporary filename;
Edit section: $request_completion $request_completion
(undocumented)
Edit section: $request_method $request_method
This variable is equal to the method of request, usually GET or POST.
Before and including 0.8.20, this variable always evaluates to the method name of the main request, not the current request if the current request is a subrequest.
Edit section: $request_uri $request_uri
This variable is equal to the complete initial URI together with the arguments;
Edit section: $scheme $scheme
The HTTP scheme (i.e. http, https). Evaluated only on demand, for example:
rewrite ^(.+)$ $scheme://example.com$1 redirect;
Edit section: $server_addr $server_addr
Equal to the server address. As a rule, for obtaining the value of this variable is done one system call. In order to avoid system call, it is necessary to indicate addresses in directives listen and to use parameter bind.
Edit section: $server_name $server_name
The name of the server.
Edit section: $server_port $server_port
This variable is equal to the port of the server, to which the request arrived;
Edit section: $server_protocol $server_protocol
This variable is equal to the protocol of request, usually this HTTP/1.0 or HTTP/1.1.
Edit section: $uri $uri
This variable is equal to current URI in the request, it can differ from initial, for example by internal redirects, or with the use of index it is file with internal redirects.
Reference:
http://www.givingtree.com.cn/entry/Nginx-Location%E5%9F%BA%E6%9C%AC%E8%AF%AD%E6%B3%95
http://wiki.nginx.org/NginxHttpCoreModule#Variables
$args this variable is equivalent to the arguments in the request line
$content_length is equal to the value of "Content_Length" in the request line.
$content_type is equivalent to the value
of "Content_Type" in the request header$document_root is equivalent to the value
specified in the root directive currently requested$document_uri is the same as $uri
$host is the same as the value specified in the "Host" line in the request header or the name of server (without the Host line) where request arrives
$limit_rate allows limited connection rate
$request_method is equivalent to method of request, usually "GET" or "POST"
$remote_addr client ip
$remote_port client port
$remote_user is equivalent to the username,
is authenticated by ngx_http_auth_basic_module$request_filename the path name of the currently requested file,
, is a combination of root or alias and URI request$request_body_file
$request_uri contains the full initial URI
parameter$query_string is the same as $args
$server_protocol is equivalent to the request protocol, using "HTTP/1.0" or "HTTP/1.1"
$server_addr request arrives at server ip. Generally, the value of this variable is obtained for the purpose of making a system call. To avoid system calls, it is necessary to specify ip in the listen directive and to use the bind parameter.
$server_name request arrives with the server name
$server_port requests the port number
of the arriving server$uri is the same as URI in the current request, and not the same as the original value, such as when redirecting internally or using index