1. 程式人生 > 其它 >NGINX常見的變數說明

NGINX常見的變數說明

通過編譯安裝的時候指定echo模組,實現列印輸出變數的值。

# 客戶端地址:10.0.0.66

root@ubuntu1804:~# curl 10.0.0.44/x/y/z?name=bob?passwd=123

remote_addr: 10.0.0.66        #客戶端ip地址

args: name=bob?passwd=123   #存放了URL中的所有引數

document_root: /data/html   #當前資源的請求的系統根目錄

document_uri: /x/y/z        #當前請求中不包含引數的URI

host: 10.0.0.44   #請求的host名稱,可以是ip地址,也可以是域名

http_user_agent: curl/7.58.0    #客戶端瀏覽器的詳細資訊

http_cookie:    #客戶端的所有cookie資訊

request_filename: /data/html/x/y/z    #當前請求的資原始檔的磁碟路徑

scheme: http  #請求的協議,例如:http,https,ftp等

scheme://host+document_uri+args: http://10.0.0.44/x/y/z?name=bob?passwd=123

request: GET /x/y/z?name=bob?passwd=123 HTTP/1.1   #表示整個請求行

proxy_add_x_forwarded_for: 10.0.0.66   #示將客戶端IP追加請求報文中X-Forwarded-For首部欄位,多個IP之間用逗號分隔
                                       # 用來實現IP透傳(後端伺服器能看到客戶端ip和代理伺服器的ip)
                                       
args: name=bob?passwd=123        #變數中存放了URL中的所有引數

request_uri: /x/y/z?name=bob?passwd=123   #請求引數的原始URI,不包含主機名

request_method: GET        #請求資源的方式,GET/PUT/DELETE等

server_addr: 10.0.0.44  #儲存了伺服器的IP地址

server_name: localhost  ##請求的伺服器的主機名
 
server_port: 80  #請求的伺服器的埠號


# 表示一個完整的請求路徑:
方法一:$scheme://$host:$document_uri?$args
# 例如:curl http://10.0.0.44/x/y/z?name=bob?passwd=123  
  http://10.0.0.44/x/y/z?name=bob?passwd=123
  
方法二:$scheme://$server_addr:$server_port$document_uri?$args;

root@ubuntu1804:~# curl 10.0.0.44:8080/x/y/z?name=bob?passwd=123
# http://10.0.0.44:8080/x/y/z?name=bob?passwd=123