$host includes port for reverse proxy

coombesy nginx-forum at nginx.us
Tue Jun 26 08:35:15 UTC 2012


I am trying to run a data server behind nginx by using a reverse proxy.
My problem is that the host name received by my application contains the
port of the proxied server not the port of the initial request i.e. a
request to http://myserver/dataserver is forwarded to /dataserver:30084
but my appliaction gets myserver:30084 instead of myserver. It is a
requirement that I know the port of the original request so as to be
able to operate on a port other than 80. As it stands I am having to
programatically remove the port.

This is part of my nginx.conf:

    server {
        listen       80;
        server_name  localhost;

        location / {
            root   html;
            index  example.html example.htm;
        }

        location /dataserver {
            proxy_pass http://localhost:30084/dataserver;
            proxy_set_header Host $host;
        }

Any help would be appreciated.

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



More information about the nginx mailing list