2

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
    >Redeploying the container fixes the issue., you should check logs of the proxy, redeploy fixing the issue seems like the the nginx connection break with upstream – Adiii Aug 08 '22 at 04:37

1 Answers1

0

check value in $serviceB_url.

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

NEOhitokiri
  • 411
  • 5
  • 9