ReverseProxy: Send hostname upstream

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

ssl on;

location / {
proxy_pass 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/

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) as
well?

Thanks

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,220185,220185#msg-220185

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) as
well?

Just remove “proxy_set_header Host $host;” from your config.

Maxim D.

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: 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:
http://forum.nginx.org/read.php?2,220185,220200#msg-220200

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”,
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;
server someServer2.akamai.com:80;
server 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:
http://forum.nginx.org/read.php?2,220185,220202#msg-220202

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs