HEAD and Nginx nginx-0.6.36-1.el5

Gena Makhomed gmm at csdoc.com
Fri Sep 11 21:06:54 MSD 2009


On Friday, September 11, 2009 at 17:21:44, xmichielx wrote:

x>     server {
x>         listen       80;
x>         server_name  _;

x>         location / {
x>             proxy_pass         http://172.23.3.14:81;
x>             proxy_redirect     off;

x> Can you what I am doing wrong here?

you disable proxy_redirect and set backend on different port.

http://wiki.nginx.org/NginxHttpProxyModule#proxy_redirect

backend may discover nonstandart port and it may generate 301 redirect including
port number. but if proxy_redirect is off - nginx can not rewrite such redirect.

better approach - configure backend on same port as frontend,
(80 in this case) but on different ip, for example 127.0.0.1,
or, at least, do not disable proxy_redirect.

fragments of my working apache backend config:

========================================================

Listen 127.0.0.1:80

NameVirtualHost *

<VirtualHost *>
    ServerName unknown-apache.example.com
    # ... ^^^ default apache virtual host
</VirtualHost>

<VirtualHost *>
    ServerName virtualhost1.example.com
    # ...
</VirtualHost>

<VirtualHost *>
    ServerName virtualhost2.example.com
    # ...
</VirtualHost>

========================================================

fragments of my corresponding nginx frontend config:

========================================================

http {

    proxy_set_header  Host $host;
    proxy_set_header  X-Real-IP $remote_addr;
    proxy_set_header  X-Nginx-Scheme $scheme;

    server {
        listen 80 default;
        server_name unknown-nginx.example.com;
        # ... ^^^ default nginx virtual host
    }

    server {
        listen 80;
        server_name virtualhost1.example.com;
        # ...
        location / {
            proxy_pass http://127.0.0.1/;
        }
    }

    server {
        listen 80;
        server_name virtualhost2.example.com;
        # ...
        location / {
            proxy_pass http://127.0.0.1/;
        }
    }
}

========================================================

also

   proxy_pass http://127.0.0.1/;

and

   proxy_pass http://127.0.0.1;

are two somewhat different directives for details see
http://wiki.nginx.org/NginxHttpProxyModule#proxy_pass

-- 
Best regards,
 Gena






More information about the nginx mailing list