Nginx http模块(十一)

来源:百度文库 编辑:神马文学网 时间:2024/04/26 08:13:19

变量

Ngx_http_core_module模块支持内置变量,他们的名字和apache的内置变量是一致的。

首先是说明客户请求title中的行,例如$http_user_agent,$http_cookie等等。

此外还有其它的一些变量

$args 此变量与请求行中的参数相等

$content_length 等于请求行的“Content_Length”的值。

$content_type 等同与请求头部的”Content_Type”的值

$document_root 等同于当前请求的root指令指定的值

$document_uri $uri一样

$host 与请求头部中“Host”行指定的值或是request到达的server的名字(没有Host行)一样

$limit_rate 允许限制的连接速率

$request_method 等同于requestmethod,通常是“GET”或“POST

$remote_addr 客户端ip

$remote_port 客户端port

$remote_user 等同于用户名,由ngx_http_auth_basic_module认证

$request_filename 当前请求的文件的路径名,由rootaliasURI request组合而成

$request_body_file

$request_uri 含有参数的完整的初始URI

$query_string $args一样

$sheeme    http模式(http,https)尽在要求是评估例如

Rewrite ^(.+)$ $sheme://example.com$;

   Redirect;

$server_protocol 等同于request的协议,使用“HTTP/1.0”或“HTTP/1.1”

$server_addr request到达的serverip,一般获得此变量的值的目的是进行系统调用。为了避免系统调用,有必要在listen指令中指明ip,并使用bind参数。

$server_name 请求到达的服务器名

$server_port 请求到达的服务器的端口号

$uri 等同于当前request中的URI,可不同于初始值,例如内部重定向时或使用index

this variable is equal to current URI in the request, it can differ from initial, for example by internal redirects, or with the use of index it is file with internal redirects.