Forum: NGINX upstream doesn't rewrite the host name?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Mark Swanson (Guest)
on 2008-12-13 00:51
(Received via mailing list)
This example from the documentation does not work for me:

http {
    upstream myproject {
        server weight=3;

    server {
        listen 80;
        location / {
            proxy_pass http://myproject;

In Firefox nginx is returning URLs like: http://myproject/...
There seems to be a step missing that converts myproject into the

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.

Mark Swanson (Guest)
on 2008-12-13 01:19
(Received via mailing list)
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.
mike (Guest)
on 2008-12-13 02:34
(Received via mailing list)
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.
This topic is locked and can not be replied to.