Nginx中全局變量整理小結(jié)
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 the HTTP header HEADER when converted to lowercase and with ‘dashes' converted to ‘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.
參考:
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 此變量與請(qǐng)求行中的參數(shù)相等
$content_length 等于請(qǐng)求行的“Content_Length”的值。
$content_type 等同與請(qǐng)求頭部的”Content_Type”的值
$document_root 等同于當(dāng)前請(qǐng)求的root指令指定的值
$document_uri 與$uri一樣
$host 與請(qǐng)求頭部中“Host”行指定的值或是request到達(dá)的server的名字(沒有Host行)一樣
$limit_rate 允許限制的連接速率
$request_method 等同于request的method,通常是“GET”或“POST”
$remote_addr 客戶端ip
$remote_port 客戶端port
$remote_user 等同于用戶名,由ngx_http_auth_basic_module認(rèn)證
$request_filename 當(dāng)前請(qǐng)求的文件的路徑名,由root或alias和URI request組合而成
$request_body_file
$request_uri 含有參數(shù)的完整的初始URI
$query_string 與$args一樣
$server_protocol 等同于request的協(xié)議,使用“HTTP/1.0”或“HTTP/1.1”
$server_addr request到達(dá)的server的ip,一般獲得此變量的值的目的是進(jìn)行系統(tǒng)調(diào)用。為了避免系統(tǒng)調(diào)用,有必要在listen指令中指明ip,并使用bind參數(shù)。
$server_name 請(qǐng)求到達(dá)的服務(wù)器名
$server_port 請(qǐng)求到達(dá)的服務(wù)器的端口號(hào)
$uri 等同于當(dāng)前request中的URI,可不同于初始值,例如內(nèi)部重定向時(shí)或使用index
相關(guān)文章
Nginx配置文件(nginx.conf)配置詳解(總結(jié))
本篇文章主要介紹了Nginx配置文件(nginx.conf)配置詳解,這對(duì)初學(xué)者有一定的參考價(jià)值,有興趣的可以了解一下。2016-12-12Mac M1 Nginx 配置多站點(diǎn)的實(shí)現(xiàn)
這篇文章主要介紹了Mac M1 Nginx 配置多站點(diǎn)的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03Nginx PHP-Fcgi中因PHP執(zhí)行時(shí)間導(dǎo)致504 Gateway Timeout錯(cuò)誤解決記錄
這篇文章主要介紹了Nginx PHP-Fcgi中因PHP執(zhí)行時(shí)間導(dǎo)致504 Gateway Timeout錯(cuò)誤解決記錄,本文的解決方法得來不易,需要的朋友可以參考下2014-09-09nginx帶寬限制?limit_rate?limit_rate_after指令
這篇文章主要為大家介紹了nginx帶寬限制?limit_rate?limit_rate_after指令詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-04-04nginx中狀態(tài)統(tǒng)計(jì)的實(shí)現(xiàn)
本文主要介紹了nginx中狀態(tài)統(tǒng)計(jì)的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-04-04Nginx?504?Gateway?Time-out的兩種最新解決方案
大家在訪問網(wǎng)站的時(shí)候通常會(huì)遇到502錯(cuò)誤、404錯(cuò)誤等,很少會(huì)遇到504錯(cuò)誤,但是在我們?nèi)ピL問大流量或者內(nèi)容數(shù)據(jù)量較多的網(wǎng)站時(shí),打開網(wǎng)頁偶爾就會(huì)出現(xiàn)504 gateway time-out,這篇文章主要給大家介紹了關(guān)于Nginx?504?Gateway?Time-out的兩種解決方案,需要的朋友可以參考下2022-08-08Nginx實(shí)現(xiàn)外網(wǎng)訪問內(nèi)網(wǎng)的步驟詳解
外網(wǎng)瀏覽器與內(nèi)網(wǎng)是不通的,但是外網(wǎng)與中間過渡服務(wù)器是通的,中間過渡服務(wù)器與內(nèi)網(wǎng)服務(wù)器是通的,這樣在外網(wǎng)訪問過渡服務(wù)器時(shí),過渡服務(wù)器再跳轉(zhuǎn)到后臺(tái)服務(wù)器,本文給大家介紹了Nginx外網(wǎng)訪問內(nèi)網(wǎng)如何實(shí)現(xiàn)步驟,需要的朋友可以參考下2023-10-10HTTP 499 狀態(tài)碼 nginx下 499錯(cuò)誤的解決辦法
HTTP狀態(tài)碼出現(xiàn)499錯(cuò)誤有多種情況,499錯(cuò)誤是什么?Nginx 499錯(cuò)誤的原因及解決方法,下面跟著腳本之家小編一起學(xué)習(xí)吧2016-06-06