2

I've got 2 upstreams and described the logic of cookie check in nginx config:

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/;
}

When i call GET http://my-url/api/..., it works, but i always get 404 for GET http://my-url/rest/..

How to fix it?

2
  • Try proxy_pass http://$back_upstream; without the /rest/ Commented Oct 11, 2021 at 12:57
  • Same result: 404 Commented Oct 11, 2021 at 17:52

1 Answer 1

1

I found solution:

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|rest) {
    proxy_pass http://$back_upstream;
}

location /rest/ is unnecessary in this case.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.