resolver does not re-resolve upstream servers after initial cache

Ruslan Ermilov ru at
Thu Nov 8 07:34:06 UTC 2012

On Wed, Nov 07, 2012 at 09:40:49PM +0100, Dave Nolan wrote:
> Using nginx 1.2.3-stable on Ubuntu 12.04 I have the following config:
>     http {
>       resolver valid=300s;
>       resolver_timeout 10s;
>       upstream myupstream {
>         server;
>       }
>       server {
>         listen 80 default_server;
>         location / {
>           proxy_pass http://myupstream$request_uri;
>           proxy_pass_request_headers on;
>           proxy_set_header Host $host;
>         }
>       }
>     }
> As I understand it, without the resolver config, nginx will resolve
>'s IP once on load and cache it until it stops or fully
> reloads the config.
> With the resolver config above, nginx should re-resolve the IP every
> 5mins.

This is not the way how it works.

A run-time resolving only takes place if URL specified in "proxy_pass"
contains variables, AND the resulting server name doesn't match any of
the configured server groups (using the "upstream" directives).  This
is documented here:

In your case, the server name is always "myupstream" and since it
matches "upstream myupstream", no run-time resolving takes place.

> However, this is not happening: I can watch tcpdump -n udp port 53 but I
> see no re-resolution taking place.
> I'd love to know how to fix this. Any advice appreciated thanks!


will resolve "" dynamically (assuming of course there's
no "upstream" in configuration).

More information about the nginx mailing list