Share the latest version of nginx built in variables daqo

  • 2020-05-12 06:47:11
  • OfStack

nginx built-in variables

The built-in variables are stored in the ngx_http_core_module module, and the names of the variables are 1 to the apache server variables. In summary, these variables represent the contents of the client request header, such as $http_user_agent, $http_cookie, and so on. Here are all the built-in variables that nginx supports:


$arg_name
The parameter name in the request, which is "?" arg_name= arg_name in the form arg_value

$args
Parameter values in the request

$binary_remote_addr
The binary form of the client address, fixed to 4 bytes in length

$body_bytes_sent
The number of bytes transmitted to the client, not counting the response header; This variable remains compatible with the "%B" parameter in Apache's mod_log_config module

$bytes_sent
Number of bytes transferred to client (1.3.8, 1.2.5)

$connection
Serial number of TCP connection (1.3.8, 1.2.5)

$connection_requests
Current number of requests for TCP connections (1.3.8, 1.2.5)

$content_length
"Content-Length" request header field

$content_type
"Content-Type" request header field

$cookie_name
cookie name

$document_root
The document root or alias of the current request

$document_uri
With $uri

$host
The priority is as follows: the host name of the HTTP request line > "HOST" request header field > Matches the requested server name

$hostname
The host name

$http_name
Matches any request header field; The last part of the variable name "name" can be replaced with any request header field. If you need to get the http request header "Accept-Language" in the configuration file, replace the "-" with the underscore and the uppercase with the lowercase, as follows: $http_accept_language.

$https
If SSL security mode is turned on, the value is "on"; otherwise, it is an empty string.

$is_args
If there are arguments in the request, the value is "?" , otherwise it is an empty string.

$limit_rate
For setting the speed limit for the response, see limit_rate.

$msec
Current Unix timestamp (1.3.9, 1.2.6)

$nginx_version
nginx version

$pid
Work process PID

$pipe
If the request comes from a pipe communication, the value is "p", otherwise it is ". "(1.3.12, 1.2.7)

$proxy_protocol_addr
Gets the client address of the proxy access server, which is an empty string in the case of direct access. (1.5.12)

$query_string
With $args

$realpath_root
The real path of the document root directory or alias currently requested converts all symbolic connections to the real path.

$remote_addr
Client address

$remote_port
Client port

$remote_user
The user name used for the HTTP basic authentication service

$request
The request address represents the client

$request_body
The client's request body
This variable can be used in location to pass the request body to the proxy server at the next level 1 through proxy_pass, fastcgi_pass, uwsgi_pass, and scgi_pass.

$request_body_file
Save the client request body in a temporary file. After file processing, this file needs to be deleted. If you want 1 to enable this, you need to set client_body_in_file_only. If you pass the secondary file to the back-end proxy server, you need to disable request body, that is, proxy_pass_request_body off, fastcgi_pass_request_body off, uwsgi_pass_request_body off, or scgi_pass_request_body off

$request_completion
The value is "OK" if the request is successful, or null if the request is incomplete or not the last part of a range request.

$request_filename
The file path of the current connection request, generated by the root or alias directive and the URI request.

$request_length
The length of the request (including the address of the request, http request header and request body) (1.3.12, 1.2.7)

$request_method
HTTP request method, usually "GET" or "POST"

$request_time
Time used to process client requests (1.3.9, 1.2.6); Time from the first byte of the client read.

$request_uri
This variable is equal to the original URI containing some client request parameters. It cannot be modified, please see $uri to change or rewrite URI without the host name, for example: "/cnphp/ test.php ? arg = freemouse ".

$scheme
The requested Web protocol, "http" or "https"

$sent_http_name
You can set any http response header field; The last part of the variable name "name" can be replaced with any response header field. If the response header Content-length needs to be set, replace the "-" with the underscore and the uppercase with the lowercase, as follows: $sent_http_content_length 4096.

$server_addr
Server side address, note that to avoid access to the linux system kernel, the ip address should be set in the configuration file in advance.

$server_name
Server name, www.cnphp.info

$server_port
Server port

$server_protocol
HTTP version of the server, usually "HTTP/1.0" or "HTTP/1.1"

$status
HTTP response code (1.3.2, 1.2.2)

$tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, $tcpinfo_rcv_space
Client TCP connection details

$time_iso8601
ISO 8610 format for server time (1.3.12, 1.2.7)

$time_local
Server time (LOG Format format) (1.3.12, 1.2.7)

$uri
The current URI in the request (without the request parameter, which is located at $args) can differ from the browser-passed value of $request_uri, which can be modified by internal redirection, or by the index directive. $uri does not contain the hostname, such as "/foo/ bar.html".

nginx has built-in global variables and their meanings

Name version description (list of variables from file ngx_http_variables)
$args 1.0.8 parameters in request;
$binary_remote_addr 1.0.8 the base 2 representation of the remote address
$body_bytes_sent 1.0.8 number of body bytes sent
$content_length 1.0.8 HTTP "Content-Length" in the request message;
$content_type 1.0.8 "Content-Type" in the request information;
$document_root 1.0.8 set the value for the root path of the current request;
$document_uri 1.0.8 is the same as $uri; Such as/test1 test2 / test php
$host 1.0.8 "Host" in the request information, if there is no Host line in the request, is equal to the server name set;
$hostname 1.0.8
$http_cookie 1.0.8 cookie information
$http_post 1.0.8
$http_referer 1.0.8 reference address
$http_user_agent 1.0.8 client agent information
$http_via 1.0.8 the Ip address of the last server accessed.
$http_x_forwarded_for 1.0.8 corresponds to the network access path.
$is_args 1.0.8
$limit_rate 1.0.8 limit on connection rate;
$nginx_version 1.0.8
$pid 1.0.8
$query_string 1.0.8 is the same as $args;
$realpath_root 1.0.8
$remote_addr 1.0.8 client address;
$remote_port 1.0.8 client port number;
$remote_user 1.0.8 client username for authentication;
$request 1.0.8 user request
$request_body 1.0.8
$request_body_file 1.0.8 send the local file name to the back end
$request_completion 1.0.8
$request_filename 1.0.8 file path of the current request, such as $request_filename: D: \ nginx/html/test1 / test2 / test php
$request_method 1.0.8 requested methods, such as "GET", "POST", etc.
$request_uri 1.0.8 request URI, with parameters; Such as http: / / localhost: 88 / test1 / test2 / test php
$scheme 1.0.8 used protocol, such as http or https, such as rewrite ^ (. +) $$scheme: / / example com $1 redirect;
$sent_http_cache_control 1.0.8
$sent_http_connection 1.0.8
$sent_http_content_length 1.0.8
$sent_http_content_type 1.0.8
$sent_http_keep_alive 1.0.8
$sent_http_last_modified 1.0.8
$sent_http_location 1.0.8
$sent_http_transfer_encoding 1.0.8
$server_addr 1.0.8 server address. If the server address is not specified by listen, this variable will be used to make a system call to get the address (a waste of resources).
$server_name 1.0.8 requested server name;
$server_port 1.0.8 the requested server port number;
$server_protocol 1.0.8 requested protocol version, "HTTP/1.0" or "HTTP/1.1";
The $uri 1.0.8 request for URI may be different from the original value, such as redirected.


Related articles: