Nginx之Embedded Variables(ngx_http_core_module)

Nginx核心模块内置变量:
# 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参数值,包括(Name,NAME)
$args :参数集合
# 测试:
# server {
# location /embedded_var {
# echo "arg_name: $arg_name";
# echo "arg_age: $arg_age";
# echo "args: $args";
# }
# }
# 结果:
# arg_name: 123
# arg_age: 100
# args: name=123&age=100&class=animal
$binary_remote_addr :客户端ip地址二进制形式,echo看不到
$body_bytes_sent :发送给客户端的字节数,不包括HTTP响应头部的大小,兼容apache的%B(apache的mod_log_config模块)
$bytes_sent :发送给客户端字节数
$connection :连接序号,依次增加
$connection_requests:一个连接,请求资源的数次
$content_length :请求首部的content_length段内容
$content_type :请求首部的content_type段内容
$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";
# }
# 结果:
# 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中是否有参数,有的话为?,否则为空
$limit_rate :设置此变量可以限制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";
# 结果:
# 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 :代理环境下的客户端IP,否则为空
$proxy_protocol_port :代理环境下的客户端端口,否则为空
$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";
# }
# 结果:
# 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部分,可以是缓存中的数据
$request_body_file :请求body部分时时的临时文件名称
$request_completion :请求完整时为ok,否则为空
$request_filename :当前请求的文件路径是基于root与alias指令和请求的uri
$request_id :此请求的id,十六进制,随机的16字节的数
$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";
# }
# 结果
# 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协议,HTTP/1.0 or HTTP/1.1
$status :响应状态码
$tcpinfo_rtt :客户端tcp连接信息,RTT(Round Trip Time)由三部分组成:链路的传播时间(propagation delay)、末端系统的处理时间、
路由器缓存中的排队和处理时间(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";
# 结果:
# 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)_第1张图片

你可能感兴趣的:(Nginx之Embedded Variables(ngx_http_core_module))