【发布时间】:2021-10-11 10:56:18
【问题描述】:
我有 2 个上游,并在 nginx 配置中描述了 cookie 检查的逻辑:
upstream back {
server backend-release.mynamespace.svc.cluster.local;
}
upstream back-preprod {
server backend-preprod.mynamespace.svc.cluster.local;
}
map $http_cookie $back_upstream {
default back;
~*is-preprod=true back-preprod;
}
location ~ ^/(api|graphql) {
proxy_pass http://$back_upstream;
}
location /rest/ {
proxy_pass http://$back_upstream/rest/;
}
当我调用 GET http://my-url/api/... 时,它可以工作,但我总是得到 404 以获得 GET http://my-url/rest/..
如何解决?
【问题讨论】:
-
试试不带
/rest/的proxy_pass http://$back_upstream; -
相同结果:404
标签: nginx nginx-reverse-proxy nginx-config nginx-location nginx-upstreams