I was developing locally in docker-compose, and had an nginx container doing a simple proxy_pass like so:

location /app/ {
    proxy_pass http://webapp:3000/;

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;


I now want to move over to kubernetes in GKE, and the last line is giving me troubles.

I tried to switch the resolver to:

    resolver kube-dns;

I also tried various other IPs and names, but I keep getting an error along the lines of:

nginx: [emerg] host not found in resolver "kube-dns"

My kubernetes setup is that I have a single pod, with 2 containers: 'webapp' and 'nginx'. I simply want to have an external service pointing to nginx that can proxy_pass to webapp.

Any ideas?


4 Answers 4


You have to specify the FQDN for the kube-dns and the services.
For GKE kube-dns standard for example, it would be: kube-dns.kube-system.svc.cluster.local
And if you're on the default namespace with your webapp service, it would be: webapp.default.svc.cluster.local

I know the original question is old, but maybe it helps someone.

  • So to clarify, FQDN of resolver in nginx config or the actual proxy_pass ? Commented Feb 26, 2020 at 1:04
  • 5
    resolver kube-dns.kube-system.svc.cluster.local ipv6=off; - this also works on Digital Ocean's Kubernetes Commented Jul 19, 2020 at 13:56
  • thank you @TobiasGassmann this seems to have fixed my DNS problems with proxy_pass
    – alex_jwb90
    Commented May 3, 2021 at 15:50
location /app {
  resolver kube-dns.kube-system.svc.cluster.local;

  proxy_pass http://webapp.default.svc.cluster.local;

This configuration with FQDN and explicit resolver (note default and kube-system explicit namespaces) worked for me (webapp is Kuberentes service name)


Achieved this locally running a cluster using Kind with the below steps:

1. Checking the DNS conf of a running pod

kubectl exec -it <pod name> -- cat /etc/resolv.conf

search default.svc.cluster.local svc.cluster.local cluster.local home
options ndots:5

2. Specifying the nameserver IP as the Nginx resolver

http {
    server {
        resolver valid=10s;

If nginx lives inside kubernetes there is no need to set the resolver since it will resolve to the correct spot. if nginx and webapp live in the same namespace you can simply

proxy_pass http://webapp

As long as your service name for the webapp is called webapp and using port 80.

If nginx lives outside then you should use a ingress controll or set the service for the webapp to a nodeport. A nodeport will open the same port on all the nodes so you can load balance between them on the nginx side.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .