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.
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):
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.
I can't help with the nginx config, because I haven't used it yet myself, but if you have a look at the config snippets in that question you linked to you'll see that Apache is running on port 8080. That's the key to having both running at once - they need to be on different ports. Because nginx is proxying for Apache the user never sees what port the latter is running on, nor does he/she need to.