您的位置:首页 > 运维架构 > Nginx

关于NGINX变量的一些测试结果

2014-11-11 14:32 309 查看
作为NGINX变量,不像正规语言那么正式。

但处理自定义和内部变量时,这些操作,也是少不了的。

geo $dollar {
default "$";
}
server {
listen 8080;
location /test {
set $foo chengang;
set $first "hello ";
echo "${first}world";
echo "foo: $foo";
echo "this is a dollar sign:$dollar";
}
location /bad {
set $bar "nginx";
echo $bar;
}
location /foo {
set $a hello;
echo "$foot = [$foot]";
echo_exec /bar;
}
location /bar {
set $foot 32;
echo "foot = [$foot]";
echo "a = [$a]";
}
}

server {
listen 8080;
location /test {
echo "uri =  $uri";
echo "request_uri = $request_uri";
echo "name: $arg_name";
echo "class: $arg_class";
set $orig_args $args;
set $args "a=3&b=4";
echo "original args: $orig_args";
echo "args: $args";
}
}

server {
listen 8080;
location /test {
set $args "foo=1&bar=2";
proxy_pass http://127.0.0.1:8081/args; }
}
server {
listen 8081;
location /args {
echo "args: $args";
}
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: