I'm running an Ubuntu 10.04 nginx server, with a reverse proxy to apache (to run munin monitoring).
This is an excerpt of my default Apache site file:
<VirtualHost *:8090>
ServerAdmin webmaster@localhost
DocumentRoot /var/cache/munin/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
And an excerpt of my example.com nginx configuration file:
location /stats {
proxy_pass http://127.0.0.1:8090/;
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_buffers 32 4k;
}
Whenever I go to example.com/stats, nginx point to apache over port 8090, and apache serves up the munin web directory. It works great.
But what if I wanted to add another domain, say example.org? I'd have another nginx configuration file, but how would I make apache's DocumentRoot
something else? Since the requests are coming into apache from nginx through localhost port 8090, how can apache determine which site the request is coming from, and which DocumentRoot
/configuration to serve it with?
I'm assuming I will have to use the headers set by nginx ($host;
or $proxy_add_x_forwarded_for;
variables?) in apache somehow…
Best Answer
I run several domains on one nginx.conf file. Try this:
then add have two virtual configs in your apache