分类: LINUX
2013-02-28 12:49:55
原文地址:nginx Variables 作者:jack_sir
The core module supports built-in variables, whose names correspond with the names of variables in Apache. First of all, there are variables which represent header lines in the client request, for example, $http_user_agent, $http_cookie, and so forth. Note that because these correspond to what the client actually sends, they are not guaranteed to exist and their meaning is defined elsewhere (e.g. in relevant standards). Furthermore, there are other variables: This variable contains the value of the GET request variable PARAMETER if present in the query string This variable is the GET parameters in request line, e.g. foo=123&bar=blahblah; The address of the client in binary form; The amount of bytes sent as part of the body of the response. Is accurate even when connections are aborted or interrupted. This variable is equal to line Content-Length in the header of request; This variable is equal to line Content-Type in the header of request; The value of the cookie COOKIE; This variable is equal to the value of directive for the current request; The same as . 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. Set to the machine's hostname as returned by The value of the HTTP header HEADER when converted to lowercase and with 'dashes' converted to 'underscores', e.g. $http_user_agent, $http_referer...; Evaluates to "?" if is set, "" otherwise. This variable allows limiting the connection rate. The version of Nginx that the server is currently running; The same as . The address of the client. The port of the client; This variable is equal to the name of user, authenticated by the ; This variable is equal to path to the file for the current request, formed from directives root or alias and URI request; This variable(0.7.58+) contains the body of the request. The significance of this variable appears in locations with directives or . Client request body temporary filename; Set to "OK" if request was completed successfully. Empty if request was not completed or if request was not the last part of a series of range requests. 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. This variable is equal to the *original* request URI as received from the client including the args. It cannot be modified. Look at $uri for the post-rewrite/altered URI. Does not include host name. Example: "/foo/bar.php?arg=baz" The HTTP scheme (i.e. http, https). Evaluated only on demand, for example: 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 and to use parameter bind. The name of the server. This variable is equal to the port of the server, to which the request arrived; This variable is equal to the protocol of request, usually this HTTP/1.0 or HTTP/1.1. This variable is equal to current URI in the request (without arguments, those are in $args.) It can differ from $request_uri which is what is sent by the browser. Examples of how it can be modified are internal redirects, or with the use of . Does not include host name. Example: "/foo/bar.html"