天天看點

Nginx常用内置變量

# argument name in the request line. 
# 請求URL中的參數名稱。
$arg_name 

# arguments in the request line. 
# 請求URL中包含的參數。
$args 

# 二進制形式的用戶端位址,ipv4通常是4比特長度,ipv6通常為16比特長度。
$binary_remote_addr 

# 發送給用戶端的不包含響應頭的位元組數;這個變量相容Apache的mod_log_config子產品的“%B”參數。
$body_bytes_sent 

# number of bytes sent to a client(1.3.8,1.2.5). 
# 發送給用戶端的位元組數。
$bytes_sent 

# connection serial number(1.3.8,1.2.5). 
# 連接配接序列号。
$connection 

# current number of requests made through a connection(1.3.8,1.2.5). 
# 目前通過連接配接發出的請求數。
$connection_requests 

# “Content-Length” request header field. 
# 請求頭中的Content-Length字段。
$content_length 

# “Content-Type” request header field. 
# 請求頭中的Content-Type字段。
$content_type 

# the name cookie. 
# cookie的名稱。
$cookie_name 

# root or alias directive’s value for the current request. 
# 目前請求的根目錄或别名的值。
$document_root 

# same as $uri. 
# 與$uri全局變量相同。
$document_uri 

# in this order of precedence:host name from the request line, or host name from the “Host” request header field, or the server name matching a request. 
# 請求URL中的主機名字段,或請求頭中的Host字段,或比對請求的server_name(nginx配置)。
$host 

# host name. 
# 主機名稱。
$hostname 

# arbitrary request header field; the last part of a variable name is the field name converted to lower case with dashes replaced by underscores. 
# 任意請求頭字段;變量名的最後一部份是轉換為小寫的字段名,通過下劃線相連。
$http_name 

# “on” if connection operates in ssl mode, or an empty string otherwise. 
# 如果是https請求方式則值為on,否則為空字元串。
$https 

# http請求資訊裡的HEADER字段。
$http_HEADER 

# 與$host相同,但如果請求資訊中沒有Host行,則可能不同。
$http_host 

# 用戶端的cookie資訊。
$http_cookie 

# 引用位址。
$http_referer 

# 用戶端代理資訊。
$http_user_agent 

# 最後一個通路伺服器的IP位址。
$http_via 

# 相當于網絡通路路徑。
$http_x_forwarded_for 

# “?” if a request line has arguments, or an empty string otherwise. 
# 如果URL包含參數則為?,否則為空字元串。
$is_args 

# setting this variable enables response rate limiting. 
# nginx配置中的limit_rate配置項的值,影響響應速度限制。
$limit_rate 

# current time in seconds with the milliseconds resolution(1.3.9,1.2.6) 
# 目前時間,機關為毫秒。
$msec 

# nginx version.
$nginx_version 

# PID of the worker process. 
# 工作程序的PID。
$pid 

# “p” if request was pipelined, “.” otherwise(1.3.12,1.2.7).
$pipe 

# 來自代理協定頭的用戶端位址,否則為空字元串。 
# proxy_protocol在nginx配置listen參數時設定。
$proxy_protocol_addr 

# client port from the PROXY protocol header, or an empty string otherwise(1.11.0). 
# 來自代理協定頭的用戶端端口,其它與$proxy_protocol_addr相同。
$proxy_protocol_port 

#  same as $args.
$query_string 

# 對應于目前請求的根目錄或别名值的絕對路徑名,所有符号連接配接都解析為真實路徑。
$realpath_root 

# client address. 
# 用戶端位址。
$remote_addr 

# client port. 
# 用戶端端口。
$remote_port 

# user name supplied with the Basic authentication. 
# 用于基本驗證的使用者名。
$remote_user 

# full original request line. 
# 完整的原始請求URL。
$request 

# request body. 
# 請求體,當proxy_pass,fastcgi_pass,uwsgi_pass和scgi_pass指令将請求體讀入緩存中時此變量值可用。
$request_body 

# name of a temporary file with the request body. 
# 請求主體的臨時檔案的名稱。
$request_body_file 

# “OK” if a request has completed, or an empty string otherwise. 
# 如果請求完成則值為OK,否則為空字元串。
$request_completion 

# file path for the current request, based on the root or alias directives, and the request URI. 
# 目前請求的檔案路徑,基于根目錄或别名指令,以及請求URI。
$request_filename 

# unique request identifier generated from 16 random bytes, in hexadecimal(1.11.0). 
# 16位随機位元組生成的唯一辨別符。
$request_id 

# request length (including request line, header, and request body)(1.3.12,1.2.7). 
# 請求長度,包含請求行,請求頭,以及請求的消息體。
$request_length 

# request method, usually “GET” or “POST”. 
# 請求方法,通常為GET或POST。
$request_method 

# 以毫秒為機關的請求處理時間;從用戶端讀取第1個位元組之後的時間。
$request_time 

# full original request URI (with arguments). 
# 完整的原始請求URI(帶有參數)。
$request_uri 

# request scheme, “http” or “https”. 
# 請求方案,http或https。
$scheme 

# 任意的響應頭字段;變量名的最後一部份是轉換為小寫的字段名,通過下劃線相連。
$sent_http_name 

# 響應結束時發送的任意字段;變量名的最後一部份是轉換為小寫的字段名,通過下劃線相連。
$send_trailer_name 

# 響應請求的伺服器位址。
$server_addr 

# 響應請求的伺服器名稱。
$server_name 

# 響應請求的伺服器端口。
$server_port 

$server_protocol 

# response status(1.3.2,1.2.2) 
# 響應狀态。
$status 

# 用戶端TCP連接配接的相關資訊,在支援TCP_INFO套接字選項的系統上可用。
$tcpinfo_rtt 
$tcpinfo_rttvar 
$tcpinfo_snd_cwnd 
$tcpinfo_rcv_space 

# local time in the ISO 8601 standard format(1.3.12,1.2.7). 
# ISO 8601标準格式下的本地時間。
$time_iso8601 

# local time in the Common Log Format(1.3.12,1.2.7). 
# 通用日志格式的本地時間。
$time_local 

# 目前請求的URI。
$uri
           

繼續閱讀