> On 19 Apr 2015, at 01:05, xuhdev <[email protected]> wrote:
>
> I'm using Nginx to act as a reverse proxy, where the backend is a name
> defined in /etc/hosts. However, Nginx does not react to the changes made in
> /etc/hosts until restarted. Is it possible to disable caching the names in
> /etc/hosts in reverse proxy?
As B.R. mentioned, the DNS lookup (via /etc/hosts or real DNS) is only done at
startup and reload.
You can change the behaviour to dynamic lookup by specifying a resolver in the
server block and then using variables in the proxy_pass. For example:
server {
resolver 8.8.8.8;
location / {
proxy_pass http://reverse_host$uri$is_args$args;
}
}
Because of the variables Nginx can't predict at startup what to perform a
lookup for. As a result it will perform the DNS lookup at request time. The
lookup response is then cached for the DNS TTL period.
CPU may be a little higher I guess but I haven't noticed anything even on high
load clusters.
This behaviour is eluded to in the documentation's last couple of paragraphs
for proxy_pass at:
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass
Jason
_______________________________________________
nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx