我正在尝试将 nginx 配置为proxy_pass基于我的请求中的 POST/GET/PUT/DELETE 参数执行操作。
我想要proxy_passto http://10.0.0.2:8000iflive=1或 to http://10.0.0.2:8081if live=0。
我尝试使用if ($arg_live = "1"),但它仅适用于 GET 请求。
谢谢,
佩德罗
我正在尝试将 nginx 配置为proxy_pass基于我的请求中的 POST/GET/PUT/DELETE 参数执行操作。
我想要proxy_passto http://10.0.0.2:8000iflive=1或 to http://10.0.0.2:8081if live=0。
我尝试使用if ($arg_live = "1"),但它仅适用于 GET 请求。
谢谢,
佩德罗
我建议你试试这个。。
if ($request_method = 'POST') {
#your_directives_here
}
if ($arg_live = "0"){
rewrite ^ /live1 last;
}
if ($arg_live = "1") {
rewrite ^ /live0 last;
}
location /live0/ {
proxy_pass http://live0-server;
}
location /live1/ {
proxy_pass http://live1-server;
}