Apache & Nginx as a reverse proxy, Virtual Hosts?
I want to set up Apache and use Nginx as a reverse proxy.
Using this set-up, should I be using Apache or Nginx to set up any virtual hosts?
Thanks in advance for any advice.
9 Replies
So when I add a new virtual server, say anothersite.com, I need to add it to both Apache & Nginx?
Looking at the nginx files, I thought I would just add location of new sites there?
so setting up from start again, I deploy Ubuntu 10.10, followthis tutorial
Get virtual hosts working as expected.
Then install Nginx & also add the virtual servers, while I change the apache listening port?
Anything serving files from a hard drive (like a web server) will need to know where those files are. So they must define a base directory (for each domain) from which to look for files. Apache (DocumentRoot) and Nginx (root) are configured independently from one another (they do not share configuration information). So both will need to be configured, no matter whether used in conjunction with each other (e.g. proxying) or not.
Only one application can bind to a port for any given IP address. Typically a trivial setup has Nginx listening on the public IP (your linode IP address) serving static items and passing on any other requests to localhost (127.0.0.1) which not visible to the world. And then Apache listening to localhost deals with PHP and passes that result back to Nginx.
Hope that helps a little
How many domains, are they all handled identically (same software?) and what is it that you're having nginx do?
If you're going to serve static files directly from nginx, you can put your data in directories named after the domain and use the host variable in the nginx config to let nginx find the files. (i.e. root /var/www/$host/public)