nginx内置变量

请求地址: http://192.168.100.66/showVar?a=1&b=2 本机IP: 192.168.1.6,
网关IP:192.168.100.1

在nginx配置类似下面的方式观察输出
location = /showVar {

return 200 "args = $args"

}

变量

例子

解析

$args

a=1&b=2

$arg_pid

$is_args

?

$query_string

a=1&b=2

请求参数

$host

192.168.100.66

主机地址

$scheme

http

协议

$limit_rate

0

需要nginx服务器配置limit_rate才能小时网络速率

$connection

1

$binary_remote_addr

二进制数据

$content_length

响应内容长度(直接返回的纯文本,正常页面应该有长度)

$content_type

响应内容类型(直接返回的纯文本,正常页面应该有类型)

$document_uri

/showVar

$document_root

/usr/local/nginx/html

映射的文件夹

$http_user_agent

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

客户端代理

$http_cookie

cookie

$http_x_forwarded_for

forward来源

$http_referer

$http_via

$https

$remote_addr

192.168.100.1

客户端公网ip(实际返回的网关IP)

$remote_user

$remote_port

11681

$request_body_file

请求体文件

$request_method

GET

请求方式

$request_filename

/usr/local/nginx/html/showVar

请求映射的文件目录

$request_length

444

请求大小

$request_uri

/showVar?a=1&b=2

请求uri

$request_time

0.000

请求时间

$server_addr

192.168.100.66

服务器IP

$server_name

localhost

服务器名

$server_port

80

服务器端口

$server_protocol

HTTP/1.1

协议版本