I've got a VPS that I've been using to experiment with web server setups. My current setup is Apache listening on port 80 serving a few sites, and proxying a few others to Nginx running on port 8080.
I'm running Ubuntu 10.04 with latest updates, but compiled Nginx v0.7.67 myself with uWSGI support.
An excerpt from my Nginx config:
server {
listen 127.0.0.1:8080;
server_name sub1.primary.com;
access_log /srv/www/sub1.primary.com/logs/access.log;
error_log /srv/www/sub1.primary.com/logs/error.log;
location /site_media/static/ {
alias /srv/www/sub1.primary.com/site_media/static/;
}
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9001;
}
}
server {
listen 127.0.0.1:8080;
server_name .secondary.com;
access_log /srv/www/secondary.com/site_media/logs/access.log;
error_log /srv/www/secondary.com/site_media/logs/error.log;
location / {
alias /srv/www/secondary.com/site_media/static/;
}
}
When I have only the first server
directive, everything works as expected. When I add the second one the first one continues to work as it was, but the domains for secondary.com bring up the site I've got running at sub1.primary.com. If I then disable the first one, I can access the stuff at secondary.com.
I'm only hosting static files at secondary.com, which is why I'm not using index
in location
.
I mention proxying from Apache for the sake of completeness, but since I'm seeing a site that Nginx is serving, I assume the problem lies there. What am I missing here?
Edit:
Turns out the thing I was missing is the ProxyPreserveHost On
command in my Apache configs, which is off by default.