Nginx HTTP框架提供的请求相关变量

L73

 

 

 

binary_remote_addr 对端二进制IPV4或IPV6 一般用作限制用户请求缓存key 

connection 递增链接序号

connection_requests  一条TCP链接上的请求数量

remote_addr 字符串格式IP地址

remote_port 字符串格式对端端口

proxy_protocol_addr 若使用了proxy_protocol协议 则返回协议中地址 否则返回空 一般用于反向代理取真正对端地址

proxy_protocol_port 同上取端口

server_addr 服务器端地址

server_prot 服务器端口

TCP_INFO Tcp内核层参数 优化性能

server_protocol 服务端协议 例如:http/1.1

request_time 请求耗时

server_name 匹配请求的server_name值

https 如果开启TLS/SSL 则返回ON 否则返回空

request_completion 请求处理完就返回OK 否则返回空

request_id 随机生成ID

request_filename 待访问文件的完整路径

document_root 由URI和root/alias规则生成的文件夹路径

realpath_root 将document_root中的软连接换成真实路径

limit_rate 返回或设置客户端响应速度上限 

body_bytes_sent 响应body包体长度

bytes_sent 全部http响应长度

status http返回码 如200

sent_trailer_名字 把响应结尾内容值返回

NGINX 系统变量

time_local 以本地时间标准输出时间‘

time_ios8601 ios8601格式输出时间

nginx_version nginx版本

pid  nginx所属worker进程id

pipe 是否用了管道

hostname 服务器主机名

msec 1970年至今的时间 单位是秒

log_format  vartest  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status bytes_sent=$bytes_sent body_bytes_sent=$body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$sent_http_abc"';

server {
    server_name var.taohui.tech localhost;
    #error_log logs/myerror.log debug;
    access_log logs/vartest.log vartest;
    listen 9090;
    
    location / {
        set $limit_rate 10k;
        return 200 '
arg_a: $arg_a,arg_b: $arg_b,args: $args
connection: $connection,connection_requests: $connection_requests
cookie_a: $cookie_a
uri: $uri,document_uri: $document_uri, request_uri: $request_uri
request: $request
request_id: $request_id
server: $server_addr,$server_name,$server_port,$server_protocol
tcpinfo:  $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, $tcpinfo_rcv_space 
host: $host,server_name: $server_name,http_host: $http_host
limit_rate: $limit_rate
hostname: $hostname
content_length: $content_length
status: $status
body_bytes_sent: $body_bytes_sent,bytes_sent: $bytes_sent
time: $request_time,$msec,$time_iso8601,$time_local
';
    }    
原文地址:https://www.cnblogs.com/jackey2015/p/10392197.html