# ReverseProxy: Send hostname upstream

**URL:** <https://www.ruby-forum.com/t/reverseproxy-send-hostname-upstream/214960>\
**Category:** NGINX\
**Created:** [December 16, 2011, 10:53pm UTC](https://www.ruby-forum.com/t/reverseproxy-send-hostname-upstream/214960 "2011-12-16T22:53:13Z")\
**Posts on this page:** 4\
**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:** [December 16, 2011, 10:53pm UTC](https://www.ruby-forum.com/t/reverseproxy-send-hostname-upstream/214960/1 "2011-12-16T22:53:13Z")

</div>

Hi,

I guess it is rather simple, but I am more of a coder than of an admin  
so not an expert in configuring webservers. I’d like to proxy an akamai  
proxy which relies on the full hostname being passed (IP is not  
enough).

server {  
listen 80;  
server\_name [proxy.mydomain.com](http://proxy.mydomain.com)

## ssl on;

location / {  
proxy\_pass [http://someServer.akamai.com:80](http://someServer.akamai.com:80);  
proxy\_set\_header Host $host;  
access\_log /var/log/nginx/upstream.log upstream;  
}  
}  
To debug, I configured an upstream log like described here:  
[http://bethesignal.org/blog/2009/07/22/watching-nginx-upstreams-with-collectd/](http://bethesignal.org/blog/2009/07/22/watching-nginx-upstreams-with-collectd/)

It seems, nginx is resolving the upstream host’s DNS-Address and uses  
the IP in all upstream requests (ommitting the hostname) which is not  
enough for the upstream host to answer correctly.

How to forward the upstream hostname (here: [someServer.akamai.com](http://someServer.akamai.com)) as  
well?

Thanks

Posted at Nginx Forum:

> **[ReverseProxy: Send hostname upstream](https://forum.nginx.org/read.php?2,220185,220185#msg-220185)**
>
> Hi, I guess it is rather simple, but I am more of a coder than of an admin so not an expert in configuring webservers. I'd like to proxy an akamai proxy which relies on the full hostname being passed (IP is not enough). server { listen 80;...

---

<div class="post-metadata">

**Author:** ![fatzopilot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/848f3c/32.png) [@fatzopilot](https://www.ruby-forum.com/u/fatzopilot)\
**Post date:** [December 17, 2011, 1:53pm UTC](https://www.ruby-forum.com/t/reverseproxy-send-hostname-upstream/214960/2 "2011-12-17T13:53:58Z")

</div>

Hello!

On Fri, Dec 16, 2011 at 04:52:44PM -0500, fatzopilot wrote:

> ## ssl on;
> 
> the IP in all upstream requests (ommitting the hostname) which is not  
> enough for the upstream host to answer correctly.
> 
> How to forward the upstream hostname (here: [someServer.akamai.com](http://someServer.akamai.com)) as  
> well?

Just remove “proxy\_set\_header Host $host;” from your config.

Maxim D.

---

<div class="post-metadata">

**Author:** ![fatzopilot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/848f3c/32.png) [@fatzopilot](https://www.ruby-forum.com/u/fatzopilot)\
**Post date:** [December 17, 2011, 4:22pm UTC](https://www.ruby-forum.com/t/reverseproxy-send-hostname-upstream/214960/3 "2011-12-17T16:22:52Z")

</div>

Hi,

thanks for your suggestion. Tried this well without success. It seems, I  
did not describe the issue properly, though.  
Just found a post (which you replied) describing a very similar  
situation: [Distinct upstream servers by name - NGINX - Ruby-Forum](http://www.ruby-forum.com/topic/860524).  
The problem in both cases is IP sharing on the backend/upstream side and  
that the upstream hostname cannot be assigned and forwarded to the  
backend dynamically by nginx. Did this change in the meantime?

Thanks  
fatzopilot

Posted at Nginx Forum:

> **[Re: ReverseProxy: Send hostname upstream](https://forum.nginx.org/read.php?2,220185,220200#msg-220200)**
>
> Hi, I guess it is rather simple, but I am more of a coder than of an admin so not an expert in configuring webservers. I'd like to proxy an akamai proxy which relies on the full hostname being passed (IP is not enough). server { listen 80;...

---

<div class="post-metadata">

**Author:** ![fatzopilot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/848f3c/32.png) [@fatzopilot](https://www.ruby-forum.com/u/fatzopilot)\
**Post date:** [December 17, 2011, 4:44pm UTC](https://www.ruby-forum.com/t/reverseproxy-send-hostname-upstream/214960/4 "2011-12-17T16:44:33Z")

</div>

One addition:

Actually, I am not trying to proxy one server (as I learned, this can be  
done by just assigning “proxy\_set\_header Host " [someServer.akamai.com](http://someServer.akamai.com)”,  
but if possible several (I just reverted to one here for boiling down  
the issue).

So I am using an upstream directive like this  
upstream akamaiBackend {  
server [someServer1.akamai.com:80](http://someServer1.akamai.com:80);  
server [someServer2.akamai.com:80](http://someServer2.akamai.com:80);  
server [someServer3.akamai.com:80](http://someServer3.akamai.com:80);  
}

Maybe it is possible to define the header\_host to be forwarded in the  
upstream directive? Haven’t found it in the docs, though…

Thanks  
fatzopilot

Posted at Nginx Forum:

> **[Re: ReverseProxy: Send hostname upstream](https://forum.nginx.org/read.php?2,220185,220202#msg-220202)**
>
> Hi, I guess it is rather simple, but I am more of a coder than of an admin so not an expert in configuring webservers. I'd like to proxy an akamai proxy which relies on the full hostname being passed (IP is not enough). server { listen 80;...
