//location ~ /test/(.*) 这样可以通过变量的方法获取后面的uri中指定的地址 set $para1 $1; $para1
location ~ /test/(.*){
set $foo hello;
echo "test test test";
echo "foo: $foo";
echo "uri = $uri";
echo "request_uri = $request_uri";
set $para1 $1;
set $para2 $2;
echo "par1:$para1";
echo "para2:$para2";
rewrite $request_uri $para1;
echo "update :$request_uri";
echo "station: $arg_station";
if ( $arg_station = '2' )
{ echo "222222";}
mirror /mirror ;
mirror /mirror2;
}
location /mirror{
access_log /usr/local/nginx/logs/access1.log main;
echo "mirror----header-2:$http_station";
proxy_pass http://10.166.18.223:8089/$para1;
proxy_set_header X-Original-URI $request_uri;
proxy_set_header station $http_station;
proxy_set_header Host $proxy_host;
proxy_pass_request_body on;
}
location /mirror2{
access_log /usr/local/nginx/logs/access2.log main ;
echo "mirror2----header-2:$http_station";
proxy_pass http://10.166.18.224:8089/$para1;
proxy_set_header X-Original-URI $request_uri;
proxy_set_header Host $proxy_host;
proxy_set_header X-Original-URI $request_uri;
proxy_set_header station $arg_station;
proxy_pass_request_body on;
}
location /test/aa{
echo "test/aa";
}