DNS resolution of backends

Maxim Dounin mdounin at mdounin.ru
Fri Jun 6 12:40:24 UTC 2014


On Thu, Jun 05, 2014 at 06:20:35PM +0300, Reinis Rozitis wrote:

> >We run a reverse proxy to Amazon S3 service. Sometime Amazon change their
> >IPs and some of them may become unresponsive and render reservse proxy
> >unusuable. Is there options to force nginx to re-resolve IPs of backends
> >lets say each 5 mins ?
> Give the upstream{} block the hostnames of the instances and add an resolver
> ( http://nginx.org/en/docs/http/ngx_http_core_module.html#resolver ).

This won't make any difference.  Names of servers in upstream{} 
blocks are resolved during configuration parsing, and won't be 
re-resolved till next configuration parsing.

To ensure periodic hostname resolution, one have to use a 
hostname (not an upstream block) in proxy_pass, and variables in 
the proxy_pass directive.  This way, nginx won't know a hostname 
in advance, and will have to use resolver to resolve it, resulting 
in a periodic hostname resolution.

(Alternatively, a special "resolve" flag for servers in upstream{} 
blocks was recently introduced of the commercial subscription, see 
But this requires commercial subscription.)

Maxim Dounin

More information about the nginx mailing list