Share the latest version nginx built-in variable Daquan _nginx

Source: Internet
Author: User
Tags lowercase response code safe mode server port

Nginx Built-in variables

Built-in variables are stored in the Ngx_http_core_module module, and the variable is named in the same way as the Apache server variable. In summary, these variables represent the contents of the client request header, such as $http_user_agent, $http _cookie, and so on. The following are all the built-in variables supported by Nginx:


$arg _name
The name of the parameter in the request, that is, "?" Behind the Arg_name=arg_value form of the Arg_name

$args
parameter values in the request

$binary _remote_addr
The binary form of the client address with a fixed length of 4 bytes

$body _bytes_sent
The number of bytes transmitted to the client, the response header is not counted, and this variable is compatible with the "%B" parameter in the Apache Mod_log_config module

$bytes _sent
Number of bytes transmitted to client (1.3.8, 1.2.5)

$connection
Serial number of the 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 for the current request

$document _uri
With $uri

$host
The priority is as follows: The host name of the HTTP request line > the "Host" Request header field > The server name that matches the request

$hostname
Host Name

$http _name
Match any request header field; the second half of the variable name can be replaced with any request header field, such as requiring an HTTP request header in the configuration file: "Accept-language", substituting "-" with an underscore, with uppercase letters replaced with lowercase, in the form of: $http _ Accept_language can be.

$https
If SSL Safe mode is turned on, the value is ' on ', otherwise an empty string.

$is _args
If there are parameters in the request, the value is "?", otherwise an empty string.

$limit _rate
The speed limit used to set the response is detailed in Limit_rate.

$msec
Current UNIX timestamp (1.3.9, 1.2.6)

$nginx _version
Nginx version

$pid
PID of the worker process

$pipe
If the request comes from pipe traffic, the value is "P", otherwise "." (1.3.12, 1.2.7)

$proxy _protocol_addr
Gets the client address of the proxy access server, which is an empty string if it is accessed directly. (1.5.12)

$query _string
With $args

$realpath _root
The current requested document root or the true path of the alias converts all symbolic connections to the true path.

$remote _addr
Client Address

$remote _port
Client Port

$remote _user
User name for HTTP base authentication Service

$request
The request address on behalf of the client

$request _body
Request body of the client
This variable can be used in location to pass the request body through Proxy_pass, Fastcgi_pass, Uwsgi_pass, and Scgi_pass to a proxy server at the next level.

$request _body_file
Save the client request body in a temporary file. This file needs to be deleted after the file processing is complete. If you need one to turn on this feature, 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, set proxy_pass_request_body off,fastcgi_pass_request_body off, Uwsgi_pass_ Request_body off, or scgi_pass_request_body off.

$request _completion
If the request succeeds, the value is "OK" if the request is not completed or the request is not the last part of a range request.

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

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

$request _method
HTTP request method, usually "get" or "POST"

$request _time
Processing the time that the client requests to use (1.3.9, 1.2.6); The timer starts at the first byte of the read client.

$request _uri
This variable equals the original URI containing some client request parameters, which cannot be modified, see $uri change or rewrite the URI, without the hostname, for example: "/cnphp/test.php?arg=freemouse".

$scheme
Requested Web protocol, "http" or "https"

$sent _http_name
You can set any HTTP response header field, and the second half of the variable name can be replaced with any response header field, and if you need to set the response header content-length, replace "-" with an underscore, with uppercase letters replaced with lowercase, in the form of: $sent _http_ Content_length 4096 can be.

$server _addr
Server-side addresses, note that to avoid accessing the Linux system kernel, you should set the IP address in advance in the configuration file.

$server _name
Server name, Www.cnphp.info

$server _port
Server port

$server _protocol
HTTP version of the server, typically "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
Specific information for client TCP connections

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

$time _local
Server time (LOG format) (1.3.12, 1.2.7)

$uri
The current URI in the request (without the request parameter, in $args) can be different from the $request_uri value passed by the browser, either through internal redirection or by using the index directive, $uri does not contain a host name, such as "/foo/bar.html".

Nginx built-in global variables and implications

Name Version description (variable list from file ngx_http_variables)
$args the parameters in the 1.0.8 request;
$binary _remote_addr 1.0.8 Remote Address binary representation
$body _bytes_sent 1.0.8 Number of message body bytes sent
The "content-length" $content _length 1.0.8 http request information;
$content the "Content-type" in the _type 1.0.8 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; Like/test1/test2/test.php.
$host the "host" in the 1.0.8 request information, equal to the set server name if there is no host row in the request;
$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 access server.
$http _x_forwarded_for 1.0.8 corresponds to a network access path.
$is _args 1.0.8
$limit the _rate 1.0.8 to the 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 user name, authentication;
$request 1.0.8 User Requests
$request _body 1.0.8
$request The local file name of the back end of the _body_file 1.0.8
$request _completion 1.0.8
$request _filename 1.0.8 The file path name of the current request, such as $request_filename:d:\nginx/html/test1/test2/test.php
$request _method 1.0.8 Request methods, such as "get", "POST" and so on;
$request the URI of the _uri 1.0.8 request, with parameters; Like http://localhost:88/test1/test2/test.php.
$scheme 1.0.8 protocols, such as HTTP or HTTPS, such as rewrite^ (. +) $ $scheme://example.com$1redirect;
$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 indicated with listen, use this variable to initiate a system call to get the address (resulting in a waste of resources);
$server _name 1.0.8 The server name to which the request arrived;
$server the server port number on which the _port 1.0.8 request arrives;
$server _protocol 1.0.8 The protocol version requested, "http/1.0" or "http/1.1";
The URI of the $uri 1.0.8 request may differ from the original value, such as redirection.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.