作为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";
}
}

