Q:

Nginx (for static files) and Apache (for dynamic content)?

So, my entire application runs on apache just fine. However, I want to test how much the requests per second increases if I put all static files through nginx instead.
I found this thread:
https://stackoverflow.com/questions/869001/how-to-serve-all-existing-static-files-directly-with-nginx-but-proxy-to-apache-t
But I have a couple problems. I'm completely new to nginx, so I'm not sure where to put the configuration. (The file is at /etc/nginx/nginx.conf, but I don't know if I just add the code to the bottom or what?)
Also, how can I have both servers running at the same time? Is it because they both listen on port 80? Right now I have to stop one to start the other, and that's as far as I've gotten.
Thanks for any help.

A:

They can be on the same port, if they are on different IPs.  Or they can be on different ports with the same IP, just not both (Could also be different IPs and Different Ports).  The multiple IP scenario is required if they will be different servers, but you could use multiple IPs on the same server.
I swear I am not trying to confuse you :-)
The location directive in the link you provided would go within the server directive (Notice that in the documentation for the location directive there is "context: server ").  If you are using a recent Ubuntu version with a default apt install, you probably want to edit default in the sites-enabled directory.  For example (kind of silly since it passes everything to Apache):
server {
    listen   80 default;

    access_log  /var/log/nginx/localhost.access.log;

    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://localhost:2500;
    }
}

In this case I am using the same server for both.  Nginx listens on 80, and Apache Listens on 2500.  You would point DNS to the ip of the Nginx server since that is the one that handles all requests by proxying for the other servers. Basically, from the client perspective, they are only talking to the Nginx server.

