假设有一个nginx配置:
server {
...
location /nakayoshi {
if ($georedirect) {
proxy_pass http://foo.bar/fa/fb/fc;
}
proxy_pass http://foo.bar/fa/fb/fd;
}
}
当我sudo nginx -t
时,它打印出来:
nginx: [emerg] "proxy_pass" cannot have URI part in location given by regular express, or inside named location, or inside "if" statement, or inside "limit_except" block in /etc/nginx/conf.d/nakayoshi.conf
我也发现rewrite
在这里帮助了我,但重定向的uri会更改为“http://foo.bar/fa/fb/fc”这样的网址。
我可以使用proxy_pass
保持重定向的uris不变吗?
答案 0 :(得分:0)
尝试这样的事情
http {
...
map $georedirect $proxyuri {
"" fa/fb/fd;
default fa/fb/fc;
}
server {
...
location /nakayoshi {
proxy_pass http://foo.bar/$proxyuri;
}
}
}