Nginx global variables

Source: Internet
Author: User

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

This variable contains the value of the GET request Variable Parameter if present in the query string
Edit section: $ ARGs

This variable is equal to arguments in the line of request;
Edit section: $ binary_remote_addr

The address of the client in binary form;
Edit section: $ body_bytes_sent

(Unmarshented)
Edit section: $ content_length

This variable is equal to line Content-Length in the header of request;
Edit section: $ content_type

This variable is equal to line Content-Type in the header of request;
Edit section: $ cookie_cookie

The value of the cookie;
Edit section: $ document_root

This variable is equal to the value of Directive root for the current request;
Edit section: $ document_uri

The same as $ Uri.
Edit section: $ 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

The value of the HTTP header when converted to lowercase and with 'dashes' converted to 'underscores', e.g. $ http_user_agent, $ http_referer ...;
Edit section: $ is_args

Evaluates to "?" If $ ARGs is set, "otherwise.
Edit section: $ limit_rate

This variable allows limiting the connection rate.
Edit section: $ QUERY_STRING

The same as $ args.
Edit section: $ remote_addr

The address of the client.
Edit section: $ remote_port

The port of the client;
Edit section: $ remote_user

This variable is equal to the name of user, authenticated by the auth Basic module;
Edit section: $ 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

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

Client request body temporary filename;
Edit section: $ request_completion

(Unmarshented)
Edit section: $ 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

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

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

The name of the server.
Edit section: $ server_port

This variable is equal to the port of the server, to which the request arrived;
Edit section: $ server_protocol

This variable is equal to the protocol of request, usually this HTTP/1.0 or HTTP/1.1.
Edit section: $ 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.

Refer:

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 equal to the parameter in the request line

$ Content_length is equal to the value of "content_length" of the request line.

$ Content_type is equivalent to the "content_type" value in the request header.

$ Document_root is equivalent to the value specified by the root command of the current request.

$ Document_uri is the same as $ Uri.

$ Host is the same as the value specified by the "host" line in the request header or the name of the server to which the request arrives (no host line ).

$ Limit_rate the allowed connection rate

$ Request_method is equivalent to the Request Method, usually "get" or "Post"

$ Remote_addr Client IP

$ Remote_port client port

$ Remote_user is equivalent to the user name and is authenticated by ngx_http_auth_basic_module.

$ Request_filename: the path name of the file currently requested. It is composed of root, alias, and URI request.

$ Request_body_file

$ Request_uri: Complete initial URI with Parameters

$ QUERY_STRING is the same as $ ARGs

$ Server_protocol is equivalent to the request protocol, using "HTTP/1.0" or "HTTP/1.1"

The IP address of the server to which $ server_addr request arrives. Generally, the value of this variable is obtained for system calls. To avoid system calls, it is necessary to specify the IP address in the listen command and use the BIND parameter.

$ SERVER_NAME name of the server to which the request arrives

$ Server_port indicates the port number of the server to which the request arrives.

$ URI is equivalent to the URI in the current request, not the initial value, for example, internal redirection or index

 

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.