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

Solution 1:

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.

Solution 2:

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.