# Using HttpMapModule with proxy\_pass got 502

**URL:** <https://www.ruby-forum.com/t/using-httpmapmodule-with-proxy-pass-got-502/225682>\
**Category:** NGINX\
**Created:** [January 23, 2013, 12:17pm UTC](https://www.ruby-forum.com/t/using-httpmapmodule-with-proxy-pass-got-502/225682 "2013-01-23T12:17:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [January 23, 2013, 12:17pm UTC](https://www.ruby-forum.com/t/using-httpmapmodule-with-proxy-pass-got-502/225682/1 "2013-01-23T12:17:39Z")

</div>

Hi everyone,

My project needs to route http request to different host with different  
domain name. I deployed HttpMapModule and proxy\_pass, and the related  
nginx.conf segment is following:

http {  
map $http\_host $backend\_servers {  
[app.example.com](http://app.example.com) localdomain1; #if changed to ip, it’s ok  
default localdomain2;  
}

server {  
listen 80;  
server\_name localhost;  
location /{  
proxy\_pass http://$backend\_servers;  
}  
…  
}

When I send the requet uri as [http://app.example.com](http://app.example.com), the result is 502  
error. But if I changed the maping value as IP address not domain name,  
it  
worked with no problem. And if I change the proxy\_pass item directly to  
[http://localdomain1](http://localdomain1), it also worked as normal.

Does the proxy\_pass + http\_map\_module not refer to DNS look? or is there  
any  
other point wrong in the nginx.conf ?

Thanks for any suggestion.

Posted at Nginx Forum:

> **[Using HttpMapModule with proxy\_pass got 502](https://forum.nginx.org/read.php?2,235450,235450#msg-235450)**
>
> Hi everyone, My project needs to route http request to different host with different domain name. I deployed HttpMapModule and proxy\_pass, and the related nginx.conf segment is following: http { map $http\_host $backend\_servers { app.example.com

---

<div class="post-metadata">

**Author:** ![amozz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@amozz](https://www.ruby-forum.com/u/amozz)\
**Post date:** [January 23, 2013, 3:21pm UTC](https://www.ruby-forum.com/t/using-httpmapmodule-with-proxy-pass-got-502/225682/2 "2013-01-23T15:21:43Z")

</div>

Hello!

On Wed, Jan 23, 2013 at 06:16:52AM -0500, amozz wrote:

> }  
> When I send the requet uri as [http://app.example.com](http://app.example.com), the result is 502  
> error. But if I changed the maping value as IP address not domain name, it  
> worked with no problem. And if I change the proxy\_pass item directly to  
> [http://localdomain1](http://localdomain1), it also worked as normal.
> 
> Does the proxy\_pass + http\_map\_module not refer to DNS look? or is there any  
> other point wrong in the nginx.conf ?
> 
> Thanks for any suggestion.

For dynamic name resolution of upstream servers to work, you have  
to configure resolver, see [Module ngx\_http\_core\_module](http://nginx.org/r/resolver).

You may also start looking into error log if something goes wrong.  
In this case it should have “no resolver defined” errors logged.

–  
Maxim D.

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**
>
> Deliver modern applications with NGINX. Explore high-performance load balancing, API gateways, and web server solutions trusted by top global enterprises.

---

<div class="post-metadata">

**Author:** ![amozz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@amozz](https://www.ruby-forum.com/u/amozz)\
**Post date:** [January 24, 2013, 8:06am UTC](https://www.ruby-forum.com/t/using-httpmapmodule-with-proxy-pass-got-502/225682/3 "2013-01-24T08:06:22Z")

</div>

Thank you Maxim.

I added the resolver, and it works now!

Posted at Nginx Forum:

> **[Re: Using HttpMapModule with proxy\_pass got 502](https://forum.nginx.org/read.php?2,235450,235522#msg-235522)**
>
> Hi everyone, My project needs to route http request to different host with different domain name. I deployed HttpMapModule and proxy\_pass, and the related nginx.conf segment is following: http { map $http\_host $backend\_servers { app.example.com
