nginx reverse proxy subdomain is redirecting
Posted
by
holtkampw
on Server Fault
See other posts from Server Fault
or by holtkampw
Published on 2011-02-24T06:50:39Z
Indexed on
2011/02/24
7:26 UTC
Read the original article
Hit count: 501
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?
© Server Fault or respective owner