设为首页 收藏本站
查看: 427|回复: 0

[经验分享] 转:Nginx全局变量

[复制链接]

尚未签到

发表于 2016-12-25 11:19:21 | 显示全部楼层 |阅读模式
  Variables
  The core module supports built-in variables, whose names correspond with the names of variables in Apache.
  First of all, there 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:
Edit section: $arg_PARAMETER $arg_PARAMETER
  This variable contains the value of the GET request variable PARAMETER if present in the query string
Edit section: $args $args
  This variable is equal to arguments in the line of request;
Edit section: $binary_remote_addr $binary_remote_addr
  The address of the client in binary form;
Edit section: $body_bytes_sent $body_bytes_sent
  (undocumented)
Edit section: $content_length $content_length
  This variable is equal to line Content-Length in the header of request;
Edit section: $content_type $content_type
  This variable is equal to line Content-Type in the header of request;
Edit section: $cookie_COOKIE $cookie_COOKIE
  The value of the cookie COOKIE;
Edit section: $document_root $document_root
  This variable is equal to the value of directive root for the current request;
Edit section: $document_uri $document_uri
  The same as $uri.
Edit section: $host $host
  This variable is equal to line Host in the header of request or name of the server processing the request if the Host header is not available.
  This variable may have a different value from $http_host when the Host input header is absent or has an empty value.
Edit section: $http_HEADER $http_HEADER
  The value of the HTTP header HEADER when converted to lowercase and with ‘dashes’ converted to ‘underscores’, e.g. $http_user_agent, $http_referer…;
Edit section: $is_args $is_args
  Evaluates to “?” if $args is set, “” otherwise.
Edit section: $limit_rate $limit_rate
  This variable allows limiting the connection rate.
Edit section: $query_string $query_string
  The same as $args.
Edit section: $remote_addr $remote_addr
  The address of the client.
Edit section: $remote_port $remote_port
  The port of the client;
Edit section: $remote_user $remote_user
  This variable is equal to the name of user, authenticated by the Auth Basic Module;
Edit section: $request_filename $request_filename
  This variable is equal to path to the file for the current request, formed from directives root or alias and URI request;
Edit section: $request_body $request_body
  This variable(0.7.58+) contains the body of the request. The significance of this variable appears in locations with directives proxy_pass or fastcgi_pass.
Edit section: $request_body_file $request_body_file
  Client request body temporary filename;
Edit section: $request_completion $request_completion
  (undocumented)
Edit section: $request_method $request_method
  This variable is equal to the method of request, usually GET or POST.
  Before and including 0.8.20, this variable always evaluates to the method name of the main request, not the current request if the current request is a subrequest.
Edit section: $request_uri $request_uri
  This variable is equal to the complete initial URI together with the arguments;
Edit section: $scheme $scheme
  The HTTP scheme (i.e. http, https). Evaluated only on demand, for example:
  rewrite ^(.+)$ $scheme://example.com$1 redirect;
  Edit section: $server_addr $server_addr
  Equal to the server address. 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.
Edit section: $server_name $server_name
  The name of the server.
Edit section: $server_port $server_port
  This variable is equal to the port of the server, to which the request arrived;
Edit section: $server_protocol $server_protocol
  This variable is equal to the protocol of request, usually this HTTP/1.0 or HTTP/1.1.
Edit section: $uri $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://www.givingtree.com.cn/entry/Nginx-Location%E5%9F%BA%E6%9C%AC%E8%AF%AD%E6%B3%95
  http://wiki.nginx.org/NginxHttpCoreModule#Variables
  $args 此变量与请求行中的参数相等
  $content_length 等于请求行的“Content_Length”的值。
  $content_type 等同与请求头部的”Content_Type”的值
  $document_root 等同于当前请求的root指令指定的值
  $document_uri 与$uri一样
  $host 与请求头部中“Host”行指定的值或是request到达的server的名字(没有Host行)一样
  $limit_rate 允许限制的连接速率
  $request_method 等同于request的method,通常是“GET”或“POST”
  $remote_addr 客户端ip
  $remote_port 客户端port
  $remote_user 等同于用户名,由ngx_http_auth_basic_module认证
  $request_filename 当前请求的文件的路径名,由root或alias和URI request组合而成
  $request_body_file
  $request_uri 含有参数的完整的初始URI
  $query_string 与$args一样
  $server_protocol 等同于request的协议,使用“HTTP/1.0”或“HTTP/1.1”
  $server_addr request到达的server的ip,一般获得此变量的值的目的是进行系统调用。为了避免系统调用,有必要在listen指令中指明ip,并使用bind参数。
  $server_name 请求到达的服务器名
  $server_port 请求到达的服务器的端口号
  $uri 等同于当前request中的URI,可不同于初始值,例如内部重定向时或使用index

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-319152-1-1.html 上篇帖子: nginx源码阅读笔记 下篇帖子: Nginx配置文件解析之二
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表