1

I have an Ngins, deployed as a pod inside the Openshift cluster, acts as reverse proxy for a backend-service. The backend-service has Kubernetes service to loadbalance the traffic between the pods (we use ha proxy as loadbalancer). The Nginx pass_proxy all the request to the service.

location /service-1/api {
  proxy_pass http://service-svc/api;
}

Anytime the Kubernetes service is recreated or it get a new IP address, the Nginx doesnt refresh the new address - this throws 504 timeout error. I tried the resolver of the Nginx with 127.0.0.1, 127.0.0.11 and other ways to force the Nginx refresh the dns lookup, along with assigning the service to a variable.

However, this doesn't solve the problem. The Nginx couldn't resolve the service, saying it cannot resolve using 127.0.0.1:53. What is the right way to put the resolver? What IP should I provide in the resolver?

vvra
  • 2,832
  • 5
  • 38
  • 82
  • You don't need to configure `resolver` if nginx is deployed as a pod inside the Openshift cluster. In `proxy_pass`, use `service name` instead of `service ip`. If it doesn't work, check if this `service name` is wrong, or if internal DNS Server fails. This link may help. https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/ – ccshih Jul 05 '19 at 02:27
  • 1
    As you can see in my question, I am using the service name only, not its IP address. Still when the service gets new IP the Nginx still calls the old one - I found this from Nginx logs. – vvra Jul 05 '19 at 06:34
  • possible duplicate [here](https://serverfault.com/questions/240476/how-to-force-nginx-to-resolve-dns-of-a-dynamic-hostname-everytime-when-doing-p) and [here](https://stackoverflow.com/questions/26956979/error-with-ip-and-nginx-as-reverse-proxy) – Mark Jul 05 '19 at 13:43
  • It might help to check pod's dnspolicy. https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy – ccshih Jul 08 '19 at 02:38

0 Answers0