# Resolver didn't work when proxy\_pass is a given domain

**URL:** <https://www.ruby-forum.com/t/resolver-didnt-work-when-proxy-pass-is-a-given-domain/210709>\
**Category:** NGINX\
**Created:** [August 15, 2011, 2:42pm UTC](https://www.ruby-forum.com/t/resolver-didnt-work-when-proxy-pass-is-a-given-domain/210709 "2011-08-15T14:42:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [August 15, 2011, 2:42pm UTC](https://www.ruby-forum.com/t/resolver-didnt-work-when-proxy-pass-is-a-given-domain/210709/1 "2011-08-15T14:42:51Z")

</div>

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 192.168.0.106;  
In nginx configuration:  
proxy\_pass [http://test.nginx.org](http://test.nginx.org);  
and the dns server configuration:  
[test.nginx.org](http://test.nginx.org) point to 192.168.0.100.  
but in debug log:  
2011/08/15 15:51:45 [error] 16819#0: \*1 connect() failed (111:  
Connection refused) while connecting to upstream, client: 192.168.0.105,  
server: [nginx.org](http://nginx.org), request: “GET / HTTP/1.1”, upstream:  
[http://206.251.255.63:80/](http://206.251.255.63:80/), host: “[test.nginx.org](http://test.nginx.org)”

it show the nginx resole [test.nginx.org](http://test.nginx.org) 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?  
2011-08-15

chinix

---

<div class="post-metadata">

**Author:** ![chinix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/35a633/32.png) [@chinix](https://www.ruby-forum.com/u/chinix)\
**Post date:** [August 15, 2011, 3:20pm UTC](https://www.ruby-forum.com/t/resolver-didnt-work-when-proxy-pass-is-a-given-domain/210709/2 "2011-08-15T15:20:37Z")

</div>

Hello!

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

> 2011/08/15 15:51:45 [error] 16819#0: \*1 connect() failed (111: Connection  
> refused) while connecting to upstream, client: 192.168.0.105, server: [nginx.org](http://nginx.org),  
> request: “GET / HTTP/1.1”, upstream: [http://206.251.255.63:80/](http://206.251.255.63:80/), host:  
> “[test.nginx.org](http://test.nginx.org)”
> 
> it show the nginx resole [test.nginx.org](http://test.nginx.org) 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 test.example.com {
     server 10.0.0.1;
 }

 location / {
     proxy_pass http://test.example.com;
 }

```

Maxim D.
