Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

So I have a frontend nginx server which will proxy to several other nginx servers (running Passenger for Rails apps).

Here's the part of the frontend nginx config in question:

server {
        listen 80;
        server_name git.domain.com;
        access_log /server/domain/log/nginx.access.log;
        error_log /server/domain/log/nginx_error.log debug;

        location / {
            proxy_pass http://127.0.0.1:8020/;
        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;
            proxy_max_temp_file_size 0;

            client_max_body_size       10m;
            client_body_buffer_size    128k;

            proxy_connect_timeout      90;
            proxy_send_timeout         90;
            proxy_read_timeout         90;

            proxy_buffer_size          4k;
            proxy_buffers              4 32k;
            proxy_busy_buffers_size    64k;
            proxy_temp_file_write_size 64k;
        }
}

server {
    listen 80;
    server_name domain.com;
    access_log /server/domain/log/nginx.access.log;
    error_log /server/domain/log/nginx_error.log debug;

    location / {
        proxy_pass http://127.0.0.1:8000/;
                proxy_set_header  X-Real-IP        $remote_addr;
                proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
                proxy_set_header  Host             $http_host;
                proxy_redirect    off;
                proxy_set_header X_FORWARDED_PROTO https;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    }
}

Finally here's the backend for git.domain.com:

server {
        listen       8020;
        #server_name  localhost;
        root /server/gitorious/gitorious/public/;
        passenger_enabled on;

        proxy_set_header  X-Real-IP        $remote_addr;
        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header  Host             $http_host;
        proxy_redirect    off;
        proxy_set_header X_FORWARDED_PROTO https;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

So here's the problem. When I type in git.domain.com, my gitorious install will redirect to domain.com. It works perfect there, but it ignores the subdomain.

At first I thought it was the server_name construct. I have tried git.domain.com, domain.com, localhost, and currently none. Any ideas?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Probably you will need to adjust proxy_redirect or some configuration in gitorious, can you snoop the frontend to backend request/response traffic to see the exact redirect gitorious is issuing ?

share|improve this answer
    
Sorry, I fixed the issues and forgot to close this. You're right. The frontend proxy_redirect command was wrong. Commenting it out made everything else work. –  holtkampw Mar 10 '11 at 17:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.