`

Nginx的一些内置变量

阅读更多
HTTP核心模块支持一些内置变量,变量名与apache里的对应。比如 $http_user_agent,$http_cookie等表示HTTP请求信息的变量。
更多变量:
$args, 请求中的参数;

$content_length, HTTP请求信息里的"Content-Length";

$content_type, 请求信息里的"Content-Type";

$document_root, 针对当前请求的根路径设置值;

$document_uri, 与$uri相同;

$host, 请求信息中的"Host",如果请求中没有Host行,则等于设置的服务器名;

$limit_rate, 对连接速率的限制;

$request_method, 请求的方法,比如"GET"、"POST"等;

$remote_addr, 客户端地址;

$remote_port, 客户端端口号;

$remote_user, 客户端用户名,认证用;

$request_filename, 当前请求的文件路径名

$request_body_file, ??

$request_uri, 请求的URI,带参数;

$query_string, 与$args相同;

$scheme, 所用的协议,比如http或者是https,比如rewrite ^(.+)$ $scheme://example.com$1 redirect;

$server_protocol, 请求的协议版本,"HTTP/1.0"或"HTTP/1.1";

$server_addr, 服务器地址,如果没有用listen指明服务器地址,使用这个变量将发起一次系统调用以取得地址(造成资源浪费);

$server_name, 请求到达的服务器名;

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

$uri, 请求的URI,可能和最初的值有不同,比如经过重定向之类的。


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/iinel/archive/2009/07/04/4321383.aspx


nginx系统变量列表来自nginx wiki

The module ngx_http_core_module supports the built-in variables, whose names correspond with the names of variables in Apache.

First of all, these are the variables, which represent the lines of the title of the client request, for example, $http_user_agent, $http_cookie and so forth.

Furthermore, there are other variables:

$arg_PARAMETER, this variable contains the value of the GET request variable PARAMETER if present in the query string

$args, this variable is equal to arguments in the line of request;

$content_length, this variable is equal to line “Content-Length” in the header of request;

$content_type, this variable is equal to line “Content-Type” in the header of request;

$document_root, this variable is equal to the value of directive root for the current request;

$document_uri, the same as $uri;

$host, this variable is equal to line “Host” in the header of request or name of the server, to whom the request arrived, if there is no this line;

$is_args evaluates to “?” if $args is set, “” otherwise.

$limit_rate, the variable allows to limit connection rate;

$query_string, the same as $args;

$request_method, this variable is equal to the method of request, usually this “GET” or “POST”;

$remote_addr, this variable is equal to the address of client;

$remote_port, this variable is equal to the port of client;

$remote_user, this variable is equal to the name of user, authenticated by ngx_http_auth_basic_module;

$request_filename, this variable is equal to path to the file for the current request, formed from directives root or alias and URI request;

$request_body_file, client request body temporary filename;

$request_uri, this variable is equal to the complete initial URI together with the arguments;

$scheme, the HTTP scheme (http, https). Evaluated only on demand, for example:

rewrite ^(.+)$ $scheme://example.com$1 redirect;
$server_protocol, this variable is equal to the protocol of request, usually this “HTTP/1.0″ or “HTTP/1.1″;

$server_addr, the variable is equal to the server address, to whom arrived the request. As a rule, for obtaining the value of this variable is done one system call. In order to avoid system call, it is necessary to indicate addresses in directives listen and to use parameter bind;

$server_name, this variable is equal to the name of the server, to whom arrived the request;

$server_port, this variable is equal to the port of the server, to which the request arrived;

$uri, 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.
参考:http://hi.baidu.com/chiron2012/item/6c8d4711a34d449698ce3375
分享到:
评论

相关推荐

    Nginx内置变量列表

    nginx内置变量列表,根据 Nginx 源码文件 ngx_http_variables.c 提取了nginx 的内置变量。

    Nginx 内置预变量都有哪些?

    Nginx 内置预变量都有哪些?

    nginx内置变量

    nginx内置变量文档, 网上收集出来的

    nginx自定义变量与内置预定义变量的使用

    内置变量 声明 可以在sever,http,location等标签中使用set命令(非唯一)声明变量,语法如下 set $变量名 变量值 注意nginx中的变量必须都以$开头。 可见性 nginx的配置文件中所有使用的变量都必须是声明过的...

    nginx 内置变量详解及隔离进行简单的拦截

    1,nginx内置变量 nginx 有很多内置变量可以进行简单的过滤。 $arg_name 请求行中的name参数。 $args 请求行中参数字符串。 $cookie_name 名为name的cookie。 与$uri相同。 $http_name 任意请求头的值;变量名的后...

    nginx 内置变量表 Excel版.rar

    经常需要配置Nginx ,其中有许多以 $ 开头的变量,经常需要查阅nginx 所支持的变量。 可能是对 Ngixn资源不熟悉,干脆就直接读源码,分析出支持的变量。 Nginx支持的http变量实现在 ngx_http_variables.c 的 ngx_...

    分享最新版 nginx内置变量 大全

    nginx内置变量 内置变量存放在 ngx_http_core_module 模块中,变量的命名方式和apache 服务器变量是一致的。总而言之,这些变量代表着客户端请求头的内容,例如$http_user_agent, $http_cookie, 等等。下面是nginx...

    appleguardu#blog#6.适配终端1

    Nginx适配PC或移动设备Nginx通过内置变量$http_user_agent,可以获取到请求客户端的userAgent,就可以用户目前处于移动端还是PC端

    Nginx配置编写时支持逻辑运算与大小写字母转换的方法

    我们可以用变量的方式来间接实现。 要实现的语句: if ($arg_unitid = 42012 && $uri ~/thumb/){ echo www.jb51.net; } 如果按照这样来配置,就会报nginx: [emerg] invalid condition错误。 可以这么来实现,如下...

    Nginx禁止指定UA访问的方法

    UA,即 Http User Agent,在 Nginx 中使用内置变量 $http_user_agent 表示,该信息作为 request header 的一部分被发往 webserver。因此,对 webserver 来说,有一种禁止访问的方式,就是对 UA 进行判断。 禁止搜索...

    nginx-tutorial:Nginx安装维护入门学习笔记,以及各种实例

    所以关于 Nginx,有这些标签:「异步」「事件」「模块化」「高性能」「高并发」「反向代理」「负载均衡」Linux系统:Centos 7 x64Nginx版本:1.11.5目录配置常用正则全局变量符号参考配置文件内置预定义变量反向代理...

    nginx下gzip配置参数详解

    Nginx自带的有gzip模块 http://wiki.nginx.org/NginxChsHttpGzipModule ,这个模块支持在线实时压缩输出数据流。...内置变量 $gzip_ratio 可以获取到gzip的压缩比率 指令: 代码如下: [#gzip gzip]

    time-sharing-client:分时民宿(客户端)

    一,启动(二)环境配置(使用开发者工具打开本地主机反向代理地址) JDK Nginx的Tomcat微信开发者工具1,Nginx(1)下载Nginx (2)配置Nginx Nginx环境变量环境变量名称:nginx_home环境变量值:nginx放置路径...

    venison:(ve)nison-为WordPress配置的高性能Ubuntu堆栈。 内置Nginx + PHP-FPM + APC +其他各种好东西。 适用于(mt)Media Temple DV开发服务器

    该脚本旨在使用Nginx堆栈在全新的(ve)服务器安装上自动化WordPress的部署。 概述 该脚本需要Ubuntu 11.04。 它为WordPress安装和配置所需的OS软件包以及MySQL / MySQL / Nginx / PHP-FPM / Postfix部署堆栈。 所有...

    PHP dotenv:自动加载环境变量-开源

    这意味着您无需在项目外编辑任何文件,并且无论您如何运行项目,Apache,Nginx,CLI甚至PHP的内置Web服务器,始终会设置所有环境变量。 它比您所知的设置环境变量的所有其他方式都容易,而且您会喜欢它的!

    phpdotenv:自动将环境变量从.env加载到getenv(),$ _ ENV和$ _SERVER

    这意味着您无需在项目外编辑任何文件,并且无论您如何运行项目,始终会设置所有环境变量-Apache,Nginx,CLI甚至PHP的内置Web服务器。 它比您所知的所有其他设置环境变量的方式都容易,而且您会喜欢的! 无需在...

    Linux Shell脚本自动化编程实战.zip

    第2章__Shell变量精讲 第3章__条件测试及流程控制 第4章__循环及并发控制 第5章__非交互式expect 第6章__数组应用实战 第7章__函数传参及返回 第8章__Shell内置命令 第9章__RE正则表达式 第10章__Sed流编辑器 第11章...

Global site tag (gtag.js) - Google Analytics