How to disable nginx internal dns cache?

my network structure is:
proxy server 1(nginx)–>proxy server2(nginx)–>web server

proxy server2 has dynamic ip address. the ip address will be changed
untime. so i use one domain for it: p2.domain.com.

but proxy server1(nginx) has been cached the ip of domain:
p2.domain.com.
so when the new ip was assigned to p2.domain.com, but proxy
server1(nginx)
still has old ip address.

i have searched on google, somebody said that nginx will cache the dns
entry
for 300 seconds(5minutes), but after 5 minutes ,event after 5 hours ,
the
proxy server1(nginx) still has old ip address,

please help me, any ideas will be appreciated.

thank you

Posted at Nginx Forum:

On Sat, May 04, 2013 at 08:42:52AM -0400, nevernet wrote:

Hi there,

my network structure is:
proxy server 1(nginx)–>proxy server2(nginx)–>web server

proxy server2 has dynamic ip address. the ip address will be changed
untime. so i use one domain for it: p2.domain.com.

Untested, but Module ngx_http_proxy_module suggests that you want a
resolver defined, and a variable for the server name to connect to.

Does that match your configuration?

f

Francis D. [email protected]

Hi!

how to disable nginx internal dns cache?

Use an IP address instead of a hostname in the proxy_pass variable.

both of them doesnt work.

Can you elaborate what “it doesn’t work” mean?

Lukas

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;
}

#error_page 404 /404.html;

redirect server error pages to the static page /50x.html

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www;
}
}

Posted at Nginx Forum:

Hello!

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

#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 Controlling nginx).


Maxim D.
http://nginx.org/en/donation.html

Hi, Maxim

thanks for you replies.

i have already checked out the problem.
Yes ,the nginx will re-resolve the domains unless reload the
configuration.
this is my problem.
because i am using Dynamic IP address.

thank you.
Daniel

Posted at Nginx Forum: