Welcome! Log In Create A New Profile

Advanced

Re: DNS cache in nginx

Maxim Dounin
July 06, 2015 10:32AM
Hello!

On Sat, Jul 04, 2015 at 09:42:06AM +0300, Shay Peretz wrote:

> Hello ,
>
> I have an A record which resolve to 2 CNAME's , the DNS failover will
> make the switch if something go wrong .
>
> The problem is that after a change the nginx stick to the OLD IP
> unless I reload it ..
> any way the Caching can be disabled ?
> I tried the following with no success :
> add valid for the resolver ,
> resolver 8.8.8.8 valid=5s;
> and or
> resolver_timeout 1s;
>
> Any recommendation to solve it ?

As long as you write host names in nginx configuration, nginx will
resolve these names while parsing the configuration. It won't
notice any changes unless the configuration is reloaded.

If you want nginx to periodically re-resolve names, there are two
options available:

1) Use proxy_pass with variables:

resolver 127.0.0.1;
set $upstream "backend.example.com";
proxy_pass http://$upstream;

When variables are used in the "proxy_pass" directive, nginx
will resolve names at runtime. See http://nginx.org/r/proxy_pass
for details.

2) Use the "resolve" flag in an upstream{} block. Only available
in nginx plus, see
http://nginx.org/en/docs/http/ngx_http_upstream_module.html#resolve
for details.

Alternatively, you may consider using nginx mechanisms to do
failover instead. See these links for some details:

http://nginx.org/en/docs/http/ngx_http_upstream_module.html
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

DNS cache in nginx

shyperetz July 04, 2015 02:44AM

Re: DNS cache in nginx

Maxim Dounin July 06, 2015 10:32AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 206
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready