# Upstream doesn't rewrite the host name?

**URL:** <https://www.ruby-forum.com/t/upstream-doesnt-rewrite-the-host-name/155529>\
**Category:** NGINX\
**Created:** [December 12, 2008, 11:51pm UTC](https://www.ruby-forum.com/t/upstream-doesnt-rewrite-the-host-name/155529 "2008-12-12T23:51:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Swanson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eada6e/32.png) [@Mark\_Swanson](https://www.ruby-forum.com/u/Mark_Swanson)\
**Post date:** [December 12, 2008, 11:51pm UTC](https://www.ruby-forum.com/t/upstream-doesnt-rewrite-the-host-name/155529/1 "2008-12-12T23:51:22Z")

</div>

This example from the documentation does not work for me:

http {  
upstream myproject {  
server 127.0.0.1:8000 weight=3;  
server 127.0.0.1:8001;  
server 127.0.0.1:8002;  
server 127.0.0.1:8003;  
}

```
server {
    listen 80;
    server_name www.domain.com;
    location / {
        proxy_pass http://myproject;
    }
}

```

}

In Firefox nginx is returning URLs like: [http://myproject/](http://myproject/)…  
There seems to be a step missing that converts myproject into the  
server\_name

I’ve tried the latest 0.7.26 and an earlier ubuntu (0.5.33-1). Both  
behave this way.

I’m new at nginx and I’m sure it’s my fault. I’m just not seeing it.  
Any help would be appreciated.

Thanks.

---

<div class="post-metadata">

**Author:** ![Mark\_Swanson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eada6e/32.png) [@Mark\_Swanson](https://www.ruby-forum.com/u/Mark_Swanson)\
**Post date:** [December 13, 2008, 12:19am UTC](https://www.ruby-forum.com/t/upstream-doesnt-rewrite-the-host-name/155529/2 "2008-12-13T00:19:28Z")

</div>

Ok, after quite a bit of searching and reading I found I needed  
something like this:

```
location = / {
    proxy_pass http://tomcatcluster;
    proxy_redirect off;
    proxy_set_header Host $host ;
    proxy_set_header X-Real-IP $remote_addr ;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
}

```

From a newb perspective, the documentation should have contained an  
example like this.

nginx looks amazing.

---

<div class="post-metadata">

**Author:** ![Mark\_Swanson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eada6e/32.png) [@Mark\_Swanson](https://www.ruby-forum.com/u/Mark_Swanson)\
**Post date:** [December 13, 2008, 1:34am UTC](https://www.ruby-forum.com/t/upstream-doesnt-rewrite-the-host-name/155529/3 "2008-12-13T01:34:58Z")

</div>

Yeah I think that is a common point of confusion. You have to pass  
along some of the headers explicitly you want, and one of the most  
important is Host.

The X-Real-IP and X-Forwarded-For may be redundant, depending on your  
application and how it uses it.
