Nginx – How to run two different web servers on the same server

apache-2.2httpdnginx

I know that you can't listen to the same port and IP using two different server processes, but apparently this is possible if you allocate a separate IP address to each. Is this the case? I'm contemplating running both ningx and Apache on the same server (I also welcome feedback on whether this is a good idea), basically because ideally I'd like to try switching over to nginx but supposedly its Tomcat support isn't great, so I'm thinking I'd need to keep apache around for that.

Has anyone done something similar; is it recommended, and how do you go about it?

Best Answer

Both apache and nginx take arguments for which addresses to listen on; if you want apache on 192.168.1.100 and nginx on 192.168.1.110, you would add the following to the respective conf files:

httpd.conf (or /etc/apache/ports.conf, depending on distro):

listen 192.168.1.100:80

nginx.conf:

server {
    # port to listen on. Can also be set to an IP:PORT
    listen 192.168.1.110:80;
    . . . 
Related Topic