Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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

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



server {
    # port to listen on. Can also be set to an IP:PORT
    . . . 
share|improve this answer

Yes, with 2 IP addresses you could have nginx and apache both listen on port 80. Alternatively you could configure apache to listed on the same IP address but on a different port and have nginx proxy requests to apache for the apache domains.

server {
    location / {
    proxy_redirect /; 

for apache listening on port 81.

share|improve this answer
Are there advantages to using a proxy? Seems like this would just add an unnecessary layer of abstraction to the mix. – Jordan Reiter Jul 1 '11 at 16:29
Very helpful, thank you! Obviously not an ideal setup, but I have an unfortunate need to run both web servers on the same IP (as some older applications expect/depend Apache). – Brian Lacy Jan 5 '13 at 20:22
@BrianLacy: You will have to use one as a proxy for the other then. – Iain Jan 5 '13 at 20:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.