nginx HttpEchoModule使我能够访问各个 nginx 变量:
location /whathost {
echo "This host is $http_host";
}
Run Code Online (Sandbox Code Playgroud)
我想查看每个可用的变量及其值,类似于setbash 中 (w/o args) 的输出。
这可能吗?
我认为没有内置的方法来显示所有变量。但是如果你查看源代码,它们似乎是在:src/http/ngx_http_variables.c 中定义的
寻找ngx_string。这是一些打印它们的 awk:
awk -F\" '/[^\w]ngx_string[^\w]/ {printf "%s:\t$%s\n", $2, $2}' src/http/ngx_http_variables.c
然后你可以编写自己的设置函数:
location = /set {
default_type text/plain;
return 200 "
# insert awk output here <-
";
}
Run Code Online (Sandbox Code Playgroud)
您可以在这里找到来源: http: //hg.nginx.org/nginx
或者你可以看到我在这里找到的变量: http: //pastie.org/9992530
| 归档时间: |
|
| 查看次数: |
4792 次 |
| 最近记录: |