resolver didn't work when proxy_pass is a given domain.

Maxim Dounin mdounin at
Mon Aug 15 13:17:46 UTC 2011


On Mon, Aug 15, 2011 at 08:42:23PM +0800, chinix wrote:

> sorry for my poor english first.
> I run nginx as a reverse proxy server,and set a dns server for it.
> I add the dns for the nginx at http directive:
>     resolver;
> In nginx configuration:
> proxy_pass;
> and the dns server configuration:
> point to
> but in debug log:
> 2011/08/15 15:51:45 [error] 16819#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client:, server:, request: "GET / HTTP/1.1", upstream:, host: ""
> it show the nginx resole from system defined dns.
> only when I configuration nginx:
> proxy_pass http://$http_host;
> the nginx resolve through the define dns.
> How to only use the defined dns for nginx even the proxy_pass source is a domain?

Directive "resolver" is only used when resolving hosts given by 
variables at run time.  To resolve hosts during configuration 
loading nginx uses normal system resolver as available via 
gethostbyname() interface.

If you want to override some name to a particular ip address, use 
"upstream" directive, i.e.

     upstream {

     location / {

Maxim Dounin

More information about the nginx mailing list