Kubernetes: 502 Bad Gateway for some assets - with Nginx Ingress

Solution 1:

As mentioned in comments, you should use the annotation nginx.ingress.kubernetes.io/service-upstream: "true":

From the nginx-ingress documentation:

Service Upstream

By default the NGINX ingress controller uses a list of all endpoints (Pod IP/port) >in the NGINX upstream configuration.

The nginx.ingress.kubernetes.io/service-upstream annotation disables that behavior and instead uses a single upstream in NGINX, the service's Cluster IP and port.

This can be desirable for things like zero-downtime deployments as it reduces the need to reload NGINX configuration when Pods come up and down. See issue #257.

Here is a github issue with a valid config running.