TCP相关变量
| 变量名 | 含义 |
|---|---|
| remote_addr | 客户端IP地址 |
| remote_port | 客户端端口 |
| server addr | 服务端IP地址 |
| server_port | 服务端端口 |
| server protocol | 服务端协议 |
| binary_remote_addr | 二进制格式的客户端IP地址 固定4字节 |
| connection | TCP连接的序号,递增 |
| connection_request | TCP连接当前的请求数量 |
| proxy_protocol_addr | 若使用了proxy_protocol协议则返回协议中地址 否则返回空 |
| proxy_protocol_port | 若使用了proxy_protocol协议则返回协议中端口 否则返回空 |
HTTP 请求过程中相关变量
| 变量名 | 含义 |
|---|---|
| uri | 请求的URL,不包含参数 |
| request_uri | 请求的URL,包含参数 |
| scheme | 协议名,http或https |
| request_method | 请求方法 |
| request_length | 全部请求的长度,包括请求行、请求头、请求体 |
| args | 全部参数字符串 |
| arg_参数名 | 特定参数值 |
| is_args | URL中有参数,则返回?否则返回空 |
| query_string | 与args相同 |
| remote_user | 由HTTP Basic Authentication协议传入的用户名 |
特殊变量
| host | 先看请求行,再看请求头,最后找server_name |
|---|---|
| http_user_agent | 用户浏览器 |
| http_referer | 从哪些链接过来的请求 |
| http_via | 经过一层代理服务器,添加对应代理服务器的信息 |
| http_x_forwarded_for | 获取用户真实IP |
| http_cookie | 用户cookie |
处理http请求中的变量
| 变量名 | 含义 |
|---|---|
| request_time | 处理请求已耗费的时间 |
| request_completion | 请求处理完成返回OK,否则返回空 |
| server_name | 匹配上请求的server_name值 |
| https | 若开启https,则返回on,否则返回空 |
| request_filename | 磁盘文件系统待访问文件的完整路径 |
| document_root | 由URI和root/alias规则生成的文件夹路径 |
| realpath_root | 将document_root中的软链接换成真实路径 |
| limit_rate | 返回响应时的速度上限值 |
