我搜索了很多论坛,发现了很多类似的主题,但没有一个适合我(我有这个配置:
upstream 8083 { server 127.0.0.1:8083; }
upstream 8084 { server 127.0.0.1:8084; }
split_clients "upstream${remote_addr}" $default {
50% 8083;
50% 8084;
}
map $arg_upstream $upstream {
default $default;
"8083" "8083";
"8084" "8084";
}
location / {
if ($arg_upstream = "8083") {
proxy_pass http://8083;
break;
}
if ($arg_upstream = "8084") {
proxy_pass http://8084;
break;
}
proxy_pass http://$default;
}
但是通过 url site/?upstream=8084之后,我没有切换到 8084 上游。如果我通过更改为来测试我的配置:
if ($arg_upstream = "8083") {
return 200 "upstream 8083"
}
if ($arg_upstream = "8084") {
return 200 "upstream 8084"
}
我看到的文字完全符合需要!我哪里错了?谢谢!