nginx全域性變數

2021-06-06 00:03:49 字數 2197 閱讀 9363

經常需要配置nginx ,其中有許多以 $ 開頭的變數,經常需要查閱nginx 所支援的變數。nginx支援的http變數實現在 ngx_http_variables.c 的 ngx_http_core_variables儲存實現:

把這些變數提取下,總結如下(1.0.8版):

$args

請求中的引數;

$binary_remote_addr

遠端位址的二進位制表示

$body_bytes_sent

已傳送的訊息體位元組數

$content_length

http請求資訊裡的"content-length";

$content_type

請求資訊裡的"content-type";

$document_root

針對當前請求的根路徑設定值;

$document_uri

與$uri相同;

$host

請求資訊中的"host",如果請求中沒有host行,則等於設定的伺服器名;

cookie 資訊

引用位址

客戶端**資訊

最後乙個訪問伺服器的ip位址。

相當於網路訪問路徑。

$is_args

$limit_rate

對連線速率的限制;

$nginx_version

$pid

$query_string

與$args相同;

$realpath_root

$remote_addr

客戶端位址;

$remote_port

客戶端埠號;

$remote_user

客戶端使用者名稱,認證用;

$request

使用者請求

$request_body

$request_body_file

發往後端的本地檔名稱

$request_completion

$request_filename

當前請求的檔案路徑名

$request_method

請求的方法,比如"get"、"post"等;

$request_uri

請求的uri,帶引數;

$scheme

所用的協議,比如http或者是https,比如rewrite^(.+)$$scheme:

伺服器位址,如果沒有用listen指明伺服器位址,使用這個變數將發起一次系統呼叫以取得位址(造成資源浪費);

$server_name

請求到達的伺服器名;

$server_port

請求到達的伺服器端口號;

$server_protocol

請求的協議版本,"http/1.0"或"http/1.1";

$uri

請求的uri,可能和最初的值有不同,比如經過重定向之類的。

Nginx 全域性變數

args 此變數與請求行中的引數相等 content length 等於請求行的 content length 的值。content type 等同與請求頭部的 content type 的值 document root 等同於當前請求的root指令指定的值 document uri 與 uri一樣...

nginx 全域性變數

名稱,說明 變數列表 於檔案 ngx http variables args,請求中的引數 binary remote addr,遠端位址的二進位制表示 body bytes sent,已傳送的訊息體位元組數 content length,http請求資訊裡的 content length cont...

Nginx 全域性變數

args 這個變數等於請求行中的引數,同 query string arg name 請求中的的引數名,即 後面的arg name arg value形式的arg name binary remote addr 客戶端位址的二進位制形式,固定長度為4個位元組 body bytes sent 傳輸給客...