# $host includes port for reverse proxy

**URL:** <https://www.ruby-forum.com/t/host-includes-port-for-reverse-proxy/220954>\
**Category:** NGINX\
**Created:** [June 26, 2012, 10:35am UTC](https://www.ruby-forum.com/t/host-includes-port-for-reverse-proxy/220954 "2012-06-26T10:35:52Z")\
**Posts on this page:** 2\
**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:** [June 26, 2012, 10:35am UTC](https://www.ruby-forum.com/t/host-includes-port-for-reverse-proxy/220954/1 "2012-06-26T10:35:52Z")

</div>

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](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:

> **[$host includes port for reverse proxy](https://forum.nginx.org/read.php?2,227919,227919#msg-227919)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![coombesy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5e9695/32.png) [@coombesy](https://www.ruby-forum.com/u/coombesy)\
**Post date:** [August 31, 2012, 6:36am UTC](https://www.ruby-forum.com/t/host-includes-port-for-reverse-proxy/220954/2 "2012-08-31T06:36:32Z")

</div>

My bad. I didn’t have correct “proxy\_set\_header” settings.

Posted at Nginx Forum:

> **[Re: $host includes port for reverse proxy](https://forum.nginx.org/read.php?2,227919,230361#msg-230361)**
>
> 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...
