Nginx之Embedded Variables(ngx_http_core_module)

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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市故痊,隨后出現(xiàn)的幾起案子顶瞳,更是在濱河造成了極大的恐慌,老刑警劉巖愕秫,帶你破解...
    沈念sama閱讀 219,366評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件慨菱,死亡現(xiàn)場離奇詭異,居然都是意外死亡戴甩,警方通過查閱死者的電腦和手機符喝,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,521評論 3 395
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來甜孤,“玉大人协饲,你說我怎么就攤上這事〗纱ǎ” “怎么了茉稠?”我有些...
    開封第一講書人閱讀 165,689評論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長把夸。 經(jīng)常有香客問我而线,道長,這世上最難降的妖魔是什么恋日? 我笑而不...
    開封第一講書人閱讀 58,925評論 1 295
  • 正文 為了忘掉前任膀篮,我火速辦了婚禮,結(jié)果婚禮上岂膳,老公的妹妹穿的比我還像新娘誓竿。我一直安慰自己,他們只是感情好谈截,可當我...
    茶點故事閱讀 67,942評論 6 392
  • 文/花漫 我一把揭開白布烤黍。 她就那樣靜靜地躺著,像睡著了一般傻盟。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上嫂丙,一...
    開封第一講書人閱讀 51,727評論 1 305
  • 那天娘赴,我揣著相機與錄音,去河邊找鬼跟啤。 笑死诽表,一個胖子當著我的面吹牛唉锌,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播竿奏,決...
    沈念sama閱讀 40,447評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼袄简,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了泛啸?” 一聲冷哼從身側(cè)響起绿语,我...
    開封第一講書人閱讀 39,349評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎候址,沒想到半個月后吕粹,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,820評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡岗仑,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,990評論 3 337
  • 正文 我和宋清朗相戀三年匹耕,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片荠雕。...
    茶點故事閱讀 40,127評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡稳其,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出炸卑,到底是詐尸還是另有隱情既鞠,我是刑警寧澤,帶...
    沈念sama閱讀 35,812評論 5 346
  • 正文 年R本政府宣布矾兜,位于F島的核電站损趋,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏椅寺。R本人自食惡果不足惜浑槽,卻給世界環(huán)境...
    茶點故事閱讀 41,471評論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望返帕。 院中可真熱鬧桐玻,春花似錦、人聲如沸荆萤。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,017評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽链韭。三九已至偏竟,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間敞峭,已是汗流浹背踊谋。 一陣腳步聲響...
    開封第一講書人閱讀 33,142評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留旋讹,地道東北人殖蚕。 一個月前我還...
    沈念sama閱讀 48,388評論 3 373
  • 正文 我出身青樓轿衔,卻偏偏與公主長得像,于是被迫代替她去往敵國和親睦疫。 傳聞我的和親對象是個殘疾皇子害驹,可洞房花燭夜當晚...
    茶點故事閱讀 45,066評論 2 355

推薦閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務發(fā)現(xiàn)蛤育,斷路器宛官,智...
    卡卡羅2017閱讀 134,668評論 18 139
  • Nginx簡介 解決基于進程模型產(chǎn)生的C10K問題,請求時即使無狀態(tài)連接如web服務都無法達到并發(fā)響應量級一萬的現(xiàn)...
    魏鎮(zhèn)坪閱讀 2,005評論 0 9
  • Nginx API for Lua Introduction ngx.arg ngx.var.VARIABLE C...
    吃瓜的東閱讀 5,790評論 0 5
  • 組織:中國互動出版網(wǎng)(http://www.china-pub.com/) RFC文檔中文翻譯計劃(http://...
    Palomar閱讀 1,573評論 0 6
  • 第一章 Nginx簡介 Nginx是什么 沒有聽過Nginx?那么一定聽過它的“同行”Apache吧缨伊!Ngi...
    JokerW閱讀 32,692評論 24 1,002