DNS resolution of backends

Hi guys

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 ?

Thanks !

Posted at Nginx Forum:

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
( Module ngx_http_core_module ).

Optionally add valid=5m; if the TTL of the domain is not optimal.

p.s. for the nginx to be more responsive you can also tweak the connect
timeouts like proxy_connect_timeout (
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_connect_timeout
) as the default is quite high - 60 seconds.

rr

Sounds exactly like what I’m looking for thank you Reinis !

Posted at Nginx Forum:

Hello!

On Thu, Jun 05, 2014 at 06:20:35PM +0300, Reinis R. 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
( Module ngx_http_core_module ).

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
Module ngx_http_upstream_module.
But this requires commercial subscription.)


Maxim D.
http://nginx.org/

Ok thank for clarifications Max

Posted at Nginx Forum: