nginx的那些内置变量

时间:2022-12-30 22:36:36

nginx在配置文件nginx.conf中可以使用很多内置变量,配置如下:

        location /info {
add_header 'Content-Type' 'text/html';
echo "http_user_agent :$http_user_agent <br>";
echo "http_cookie :$http_cookie <br>";
echo "http_user_agent :$http_user_agent <br>";
echo "http_cookie :$http_cookie <br>";
echo "arg_name :$arg_name <br>";
echo "args :$args <br>";
echo "binary_remote_addr :$binary_remote_addr <br>";
echo "body_bytes_sent :$body_bytes_sent <br>";
echo "bytes_sent :$bytes_sent <br>";
echo "connection :$connection <br>";
echo "connection_requests :$connection_requests <br>";
echo "content_length :$content_length <br>";
echo "content_type :$content_type <br>";
echo "cookie_name :$cookie_name <br>";
echo "document_root :$document_root <br>";
echo "document_uri :$document_uri <br>";
echo "uri :$uri <br>";
echo "host :$host <br>";
echo "hostname :$hostname <br>";
echo "http_name :$http_name <br>";
echo "https :$https <br>";
echo "is_args :$is_args <br>";
echo "limit_rate :$limit_rate <br>";
echo "msec :$msec <br>";
echo "nginx_version :$nginx_version <br>";
echo "pid :$pid <br>";
echo "pipe :$pipe <br>";
echo "proxy_protocol_addr :$proxy_protocol_addr <br>";
echo "query_string :$query_string <br>";
echo "realpath_root :$realpath_root <br>";
echo "remote_addr :$remote_addr <br>";
echo "remote_port :$remote_port <br>";
echo "remote_user :$remote_user <br>";
echo "request :$request <br>";
echo "request_body :$request_body <br>";
echo "request_body_file :$request_body_file <br>";
echo "request_completion :$request_completion <br>";
echo "request_filename :$request_filename <br>";
echo "request_length :$request_length <br>";
echo "request_method :$request_method <br>";
echo "request_time :$request_time <br>";
echo "request_uri :$request_uri <br>";
echo "scheme :$scheme <br>";
echo "sent_http_name :$sent_http_name <br>";
echo "server_addr :$server_addr <br>";
echo "server_name :$server_name <br>";
echo "server_port :$server_port <br>";
echo "server_protocol :$server_protocol <br>";
echo "status :$status <br>";
echo "tcpinfo_rtt :$tcpinfo_rtt <br>";
echo "tcpinfo_rttvar :$tcpinfo_rttvar <br>";
echo "tcpinfo_snd_cwnd :$tcpinfo_snd_cwnd <br>";
echo "tcpinfo_rcv_space :$tcpinfo_rcv_space <br>";
echo "tcpinfo_rtt :$tcpinfo_rtt <br>";
echo "tcpinfo_rttvar :$tcpinfo_rttvar <br>";
echo "tcpinfo_snd_cwnd :$tcpinfo_snd_cwnd <br>";
echo "tcpinfo_rcv_space :$tcpinfo_rcv_space <br>";
echo "tcpinfo_rtt :$tcpinfo_rtt <br>";
echo "tcpinfo_rttvar :$tcpinfo_rttvar <br>";
echo "tcpinfo_snd_cwnd :$tcpinfo_snd_cwnd <br>";
echo "tcpinfo_rcv_space :$tcpinfo_rcv_space <br>";
echo "tcpinfo_rtt :$tcpinfo_rtt <br>";
echo "tcpinfo_rttvar :$tcpinfo_rttvar <br>";
echo "tcpinfo_snd_cwnd :$tcpinfo_snd_cwnd <br>";
echo "tcpinfo_rcv_space :$tcpinfo_rcv_space <br>";
echo "time_iso8601 :$time_iso8601 <br>";
echo "time_local :$time_local <br>";
echo "uri :$uri <br>";
}

  

测试结果如下:

http://127.0.0.1/info?a=1&b=2

http_user_agent :Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36
http_user_agent :Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36
arg_name :
args :a=1&b=2
binary_remote_addr :�w�
body_bytes_sent :0
bytes_sent :0
connection :6
connection_requests :2
content_length :
content_type :
cookie_name :
document_root :/opt/openresty/nginx/html
document_uri :/info
uri :/info
http_name :
https :
is_args :?
limit_rate :0
msec :1450346470.512
nginx_version :1.9.3
pid :8161
pipe :.
proxy_protocol_addr :
query_string :a=1&b=2
realpath_root :/opt/openresty/nginx/html
remote_addr :127.0.0.1
remote_port :57621
remote_user :
request :GET /info?a=1&b=2 HTTP/1.1
request_body :
request_body_file :
request_completion :
request_filename :/opt/openresty/nginx/html/info
request_length :391
request_method :GET
request_time :0.000
request_uri :/info?a=1&b=2
scheme :http
sent_http_name :
server_addr :127.0.0.1
server_name :localhost
server_port :80
server_protocol :HTTP/1.1
status :200
tcpinfo_rtt :73750
tcpinfo_rttvar :99500
tcpinfo_snd_cwnd :10
tcpinfo_rcv_space :14480
tcpinfo_rtt :73750
tcpinfo_rttvar :99500
tcpinfo_snd_cwnd :10
tcpinfo_rcv_space :14480
tcpinfo_rtt :73750
tcpinfo_rttvar :99500
tcpinfo_snd_cwnd :10
tcpinfo_rcv_space :14480
tcpinfo_rtt :73750
tcpinfo_rttvar :99500
tcpinfo_snd_cwnd :10
tcpinfo_rcv_space :14480
time_iso8601 :2015-12-17T18:01:10+08:00
time_local :17/Dec/2015:18:01:10 +0800
uri :/info

参考:

http://www.cnphp.info/nginx-embedded-variables-lasted-version.html

https://openresty.org/download/agentzh-nginx-tutorials-zhcn.html

http://openresty.org/#eBooks

nginx的那些内置变量的更多相关文章

  1. 使用正则表达式来截取nginx中的内置变量

    nginx 中的内置变量都可以通过 if 指令 + 正则表达式来进行截取,截取之后的结果通过正则表达式的分组来进行引用 比如:从请求中传过来的一个名为 ssl_client_s_dn 的变量,它的值是 ...

  2. Nginx核心模块内置变量

    本文根据Nginx官网整理了Nginx的ngx_http_core_module模块的内置变量,可与Apache做对比参考.随后做了一次测试观察各变量的值,并附上测试结果. 1.变量列表 $arg_n ...

  3. Nginx内置变量及正则语法

    对于很多Nginx初学者来说,配置文件是必须要看懂的.但是当公司的Nginx配置文件放在你面前的时候你总会被一些带着"$"符号和一大推看不懂的的正则给正懵逼.没错带着"$ ...

  4. nginx内置变量总结

    nginx内置变量 2019-02-28 变量名称 变量用途 $atg_PARAMETER      客户端GET请求中   PARAMETER字段的值                        ...

  5. 【nginx】nginx配置文件结构,内置变量及参数调优

    Nginx的配置文件是一个纯文本文件,它一般位于Nginx安装目录的conf目录下,整个配置文件是以block的形式组织的.每个block一般以一个大括号“{”来表示.block 可以分为几个层次,整 ...

  6. nginx 内置变量

    http://blog.sina.com.cn/s/articlelist_1834459124_1_1.html  nginx内置变量杂谈 http://nginx.org/en/docs/http ...

  7. nginx内置变量 大全

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

  8. nginx内置变量详解-乾颐堂

    nginx的配置文件中可以使用的内置变量以美元符$开始,也有人叫全局变量.其中,部分预定义的变量的值是可以改变的. $arg_PARAMETER 这个变量值为:GET请求中变量名PARAMETER参数 ...

  9. nginx基础学习第二篇:nginx内置变量的使用

    ngx_http_core模块提供的内置变量有很多,常见的有 $uri,用来获取当前请求的uri,不含请求参数. $request_uri,用来获取请求最原始的uri,包含请求参数,且未解码. $re ...

随机推荐

  1. Recover data from reference electrode via EEGLab 用EEGLab恢复参考电极数据

    The data of scanning reference electrode will not show initially. Here is a summary of recovering it ...

  2. C&num; IntPtr转换为Byte&lbrack;&rsqb;

    [DllImport("OpenNetStream.dll")] public static extern int OpenSDK_Data_GetDevList(IntPtr s ...

  3. Docker私有仓库 Registry中的镜像管理

    这里主要介绍Registry v2的版本 查看Registry仓库中现有的镜像: # curl -XGET http://10.0.30.6:5000/v2/_catalog# curl -XGET ...

  4. Qt解析XML文件(QXmlStreamReader)

    (2013-08-03 10:53:53) 转载▼       如何使用QXmlStreamReader来解析格式良好的XML,Qt的文档中指出,它是一种更快.更方便的Qt自己的SAX解析器(QXml ...

  5. iframe页面控制父页面跳转

    <script> window.onload=function(){   window.location.href="http://www.baidu.com";    ...

  6. java系列--过滤器

    在web.xml配置过滤器:过滤器一定要放在所以Servlet前面 过滤器的生命周期: 过滤器的应用: 1.编码格式 2.权限验证 3.数据库关闭

  7. RabbitMQ windows安装官方文档翻译!

    RabbitMQ Windows安装和配置 下载地址 官网windows下载地址: http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/r ...

  8. scp从远程指定目录拷贝文件到本地指定目录

    scp从远程指定目录拷贝文件到本地指定目录 [root@picts ~]# cat /root/scp_pictures.sh #!/bin/bash # Function: copy files f ...

  9. ZBX&lowbar;NOTSUPPORTED&colon; Cannot obtain filesystem information&colon; &lbrack;13&rsqb; Permission denied

    zabbix有默认两条自动发现规则,其中一条是自动发现已挂载文件系统,但笔者的三个挂载文件系统中两个监控成功了,一个失败 agentd端挂载情况: 仔细研究sdb1的挂载点,发现它是挂载在xiami用 ...

  10. 《剑指offer》-二叉搜索树与双向链表

    输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表.要求不能创建任何新的结点,只能调整树中结点指针的指向. 题目的描述不是很习惯.题目的意思是把二叉树从左到右遍历,相当于双向链表的遍历. 其实 ...