Nginx核心模塊內(nèi)置變量:
# http://nginx.org/en/docs/http/ngx_http_core_module.html#variables
# The ngx_http_core_module module supports embedded variables with names matching the Apache Server variables. First of all, these are variables representing client request header fields, such as $http_user_agent, $http_cookie, and so on. Also there are other variables:
==============
$arg_name :uri中name參數(shù)值,包括(Name,NAME)
$args :參數(shù)集合
# 測試:
# server {
# location /embedded_var {
# echo "arg_name: $arg_name";
# echo "arg_age: $arg_age";
# echo "args: $args";
# }
# }
# 結(jié)果:
# arg_name: 123
# arg_age: 100
# args: name=123&age=100&class=animal
$binary_remote_addr :客戶端ip地址二進制形式岛琼,echo看不到
$body_bytes_sent :發(fā)送給客戶端的字節(jié)數(shù)眷昆,不包括HTTP響應頭部的大小,兼容apache的%B(apache的mod_log_config模塊)
$bytes_sent :發(fā)送給客戶端字節(jié)數(shù)
$connection :連接序號上荡,依次增加
$connection_requests:一個連接哎壳,請求資源的數(shù)次
$content_length :請求首部的content_length段內(nèi)容
$content_type :請求首部的content_type段內(nèi)容
$cookie_name :cooike的名字
$document_root :當前請求root或別名目錄的絕對路徑
$document_uri :當前請求的uri
$uri :當前請求的uri
# 測試:
# location /embedded_var {
# echo "document_root: $document_root";
# echo "document_uri: $document_uri";
# echo "uri: $uri";
# }
# 結(jié)果:
# document_root: /usr/local/nginx1/html
# document_uri: /embedded_var
# uri: /embedded_var
$host :匹配順序:url中的主機名---請求首部中Host段---服務器名稱
$hostname :服務器主機名稱
$http_name :類似$http_XXX,插入在http首部中以http_開頭的變量
$https :開啟ssl模式毅待,為on ,否則為空
$is_args :請求uri中是否有參數(shù),有的話為?归榕,否則為空
$limit_rate :設(shè)置此變量可以限制http響應速率
$msec :current time in seconds with the milliseconds resolution
# 測試:
# echo "host: $host";
# echo "hostname: $hostname";
# echo "http_name: $http_name";
# echo "https: $https";
# echo "is_args: $is_args";
# echo "limit_rate: $limit_rate";
# echo "msec: $msec";
# 結(jié)果:
# host: 10.0.0.254
# hostname: oela
# http_name:
# https:
# is_args: ?
# limit_rate: 0
# msec: 1487171086.441
$nginx_version:nginx版本號
$pid :工作進程的PID號
$pipe :"p" if request was pipelined,"." otherwise
$proxy_protocol_addr :代理環(huán)境下的客戶端IP尸红,否則為空
$proxy_protocol_port :代理環(huán)境下的客戶端端口,否則為空
$query_string :與$args相同
$realpath_root :root目錄的絕對路徑
$remote_addr :客戶端IP
$remote_port :客戶端端口
$remote_user :基本認證的用戶名
# 測試:
# { echo "nginx_version: $nginx_version";
# echo "pid: $pid";
# echo "pipe: $pipe";
# echo "proxy_protocol_addr: $proxy_protocol_addr";
# echo "proxy_protocol_port: $proxy_protocol_port";
# echo "query_string: $query_string";
# echo "realpath_root: $realpath_root";
# echo "remote_addr: $remote_addr";
# echo "remote_port: $remote_port";
# echo "remote_user: $remote_user";
# }
# 結(jié)果:
# nginx_version: 1.11.10
# pid: 12643
# pipe: .
# proxy_protocol_addr:
# proxy_protocol_port:
# query_string: name=123&age=100&class=animal
# realpath_root: /usr/local/nginx1/html
# remote_addr: 10.0.0.1
# remote_port: 50167
# remote_user:
$request :完整的原始請求
$request_body :請求body部分刹泄,可以是緩存中的數(shù)據(jù)
$request_body_file :請求body部分時時的臨時文件名稱
$request_completion :請求完整時為ok外里,否則為空
$request_filename :當前請求的文件路徑是基于root與alias指令和請求的uri
$request_id :此請求的id,十六進制,隨機的16字節(jié)的數(shù)
$request_length :請求的大小特石,包括請求行盅蝗,請求頭部,請求的body部分
$request_method :請求使用的方法:GET or POST
$request_time :請求完成的時間姆蘸,精確到毫秒級別
$request_uri :完整的原始請求URI
# 測試
# { echo "request: $request";
# echo "request_body: $request_body";
# echo "request_body_file: $request_body_file";
# echo "request_completion: $request_completion";
# echo "request_filename: $request_filename";
# echo "request_id: $request_id";
# echo "request_length: $request_length";
# echo "request_method: $request_method";
# echo "request_time: $request_time";
# echo "request_uri: $request_uri";
# }
# 結(jié)果
# request: GET /embedded_var?name=123&age=100&class=animal HTTP/1.1
# request_body:
# request_body_file:
# request_completion:
# request_filename: /usr/local/nginx1/html/embedded_var
# request_id: 9db874486add51c755619efb10aaf5c2
# request_length: 205
# request_method: GET
# request_time: 0.000
# request_uri: /embedded_var?name=123&age=100&class=animal
$schemae :請求的scheme, http or https
$sent_http_name :類似$sent_http_XXX
$server_addr :接收客戶端請求的服務器IP
$server_name :接收客戶端請求的服務器名稱
$server_port :接收客戶端請求的服務器端口
$server_protocol :客戶端請求使用的http協(xié)議墩莫,HTTP/1.0 or HTTP/1.1
$status :響應狀態(tài)碼
$tcpinfo_rtt :客戶端tcp連接信息芙委,RTT(Round Trip Time)由三部分組成:鏈路的傳播時間(propagation delay)、末端系統(tǒng)的處理時間贼穆、
路由器緩存中的排隊和處理時間(queuing delay)题山。
$tcpinfo_rttvar :
$tcpinfo_snd_cwnd
$tcpinfo_rcv_space
$time_iso8601 :本地時間 iso 8601標準格式
$time_local :本地時間 Common日志模式
# 測試:
# { echo "scheme: $scheme";
# echo "sent_http_name: $sent_http_name";
echo "server_addr: $server_addr";
echo "server_name: $server_name";
echo "server_port: $server_port";
echo "server_protocol: $server_protocol";
echo "status: $status";
echo "tcpinfo_rtt: $tcpinfo_rtt";
echo "tcpinfo_rttvar: $tcpinfo_rttvar";
echo "tcpinfo_snd_cwnd: $tcpinfo_snd_cwnd";
echo "tcpinfo_rcv_space: $tcpinfo_rcv_space";
echo "time_iso8601: $time_iso8601";
echo "time_local: $time_local";
# 結(jié)果:
# scheme: http
# sent_http_name:
# server_addr: 10.0.0.254
# server_name:
# server_port: 80
# server_protocol: HTTP/1.1
# status: 200
# tcpinfo_rtt: 50250
# tcpinfo_rttvar: 58750
# tcpinfo_snd_cwnd: 10
# tcpinfo_rcv_space: 14480
# time_iso8601: 2017-02-16T00:55:57+08:00
# time_local: 16/Feb/2017:00:55:57 +0800
Nginx之Embedded Variables(ngx_http_core_module)
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來甜孤,“玉大人协饲,你說我怎么就攤上這事〗纱ǎ” “怎么了茉稠?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀的道長把夸。 經(jīng)常有香客問我而线,道長,這世上最難降的妖魔是什么恋日? 我笑而不...
- 正文 為了忘掉前任膀篮,我火速辦了婚禮,結(jié)果婚禮上岂膳,老公的妹妹穿的比我還像新娘誓竿。我一直安慰自己,他們只是感情好谈截,可當我...
- 文/花漫 我一把揭開白布烤黍。 她就那樣靜靜地躺著,像睡著了一般傻盟。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上嫂丙,一...
- 文/蒼蘭香墨 我猛地睜開眼袄简,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了泛啸?” 一聲冷哼從身側(cè)響起绿语,我...
- 正文 年R本政府宣布矾兜,位于F島的核電站损趋,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏椅寺。R本人自食惡果不足惜浑槽,卻給世界環(huán)境...
- 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望返帕。 院中可真熱鬧桐玻,春花似錦、人聲如沸荆萤。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽链韭。三九已至偏竟,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間敞峭,已是汗流浹背踊谋。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務發(fā)現(xiàn)蛤育,斷路器宛官,智...
- Nginx簡介 解決基于進程模型產(chǎn)生的C10K問題,請求時即使無狀態(tài)連接如web服務都無法達到并發(fā)響應量級一萬的現(xiàn)...
- Nginx API for Lua Introduction ngx.arg ngx.var.VARIABLE C...
- 組織:中國互動出版網(wǎng)(http://www.china-pub.com/) RFC文檔中文翻譯計劃(http://...