why does Nginx Proxy pass starts giving 502 error response

Viewed 60

I have deployed an nginx container in a K8 cluster using nginx proxy_pass to proxy to few other services deployed in the same cluster but in different namespace. The proxying works fine when the container is deployed but starts giving 502 error intermittently after some time. I am using a resolver and set variable to proxy to other services. Redeploying the container fixes the issue.

Here is my same location config:

location ^~ /serviceB/ {
            keepalive_timeout  10s;  
            proxy_set_header X-Forwarded-Host $host;  
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;    
            rewrite ^/serviceB\/(.*) /$1 break;
            proxy_pass $serviceB_url;
        }
1 Answers

check value in $serviceB_url.

You can show this in header response, just add before proxy_pass line: add_header my_header $serviceB_url;

Related