how to disable nginx internal dns cache?

Maxim Dounin mdounin at mdounin.ru
Mon May 6 13:59:10 UTC 2013


Hello!

On Mon, May 06, 2013 at 09:31:14AM -0400, nevernet wrote:

> i have resolver define, see below configuration:
> 
> server {
>  listen   80;
>  server_name  xx.com;
>  access_log  /var/log/nginx/xx-nginx.access.log;
>  error_log  /var/log/nginx/xx-nginx_error.log debug;
> 
> # resolver 8.8.8.8;
> # resolver_timeout 1s;
> 
>  #set your default location
>  location / {
> #  resolver 8.8.8.8 valid=5s;  # i have defined resolver at here ,and also
> tried to add it in "http" section in nginx.conf file.   but both of them
> doesnt work. 
>   proxy_pass         http://p2.domain.com;
>  }

Resolver directive is only used if you use variables in 
proxy_pass.  Use something like this to force resolver usage:

    location / {
        set $backend "p2.domain.com";
        proxy_pass http://$backend;
    }

By default nginx resolvers hostnames to ip addresses while loading   
configuration, and will not re-resolve them unless you'll reload 
configuration (see http://nginx.org/en/docs/control.html).

-- 
Maxim Dounin
http://nginx.org/en/donation.html



More information about the nginx mailing list