Question

Has anyone had any success running two different web servers -- such as Apache and CherryPy -- alongside each other on the same machine? I am experimenting with other web servers right now, and I'd like to see if I can do my experiments while keeping my other sites up and running. You could say that this isn't so much a specific-software question as it is a general networking question.

  • I know it's possible to run two web servers on different ports; but is there any way to configure them so that they can run on the same port (ie, they both run on port 80)?
  • The web servers would not be serving files from the same domains. For example, Apache might serve up documents from foo.domain.com, and the other web server would serve from bar.domain.com.

I do know that this is not an ideal configuration. I'd just like to see if it can be done before I go sprinting down the rabbit hole. :)

Was it helpful?

Solution

You can't have two processes bound to the same port on the same IP address. You can add another IP address to the box and have each server listen on one.

Another option is to proxy pass one server to the other. With Apache, you could do something like:

NameVirtualHost *
<virtualhost *>
  ServerName other.site.com

  # assumes CherryPy listens on port 8080
  ProxyPass / http://127.0.0.1:8080/
  ProxyPassReverse / http://127.0.0.1:8080/
</Virtualhost>

That's a pretty quick example, but you can always check the ProxyPass documentation. Remember though, the application being proxyed to will get 127.0.0.1 in it's logs instead of the requester's IP address. Some web servers (apache does with mod_rpaf) can substitute the X-Forwarded-For header in place of the wrong IP address. Possibly CherryPy has this?

OTHER TIPS

Your best bet would be putting Apache httpd in front of port 80 and relay requests meant for other servers through Apache by using modules. Most popular scenario would be Tomcat behind Apache where you'll be able to run both php and jsp applications.

I'm not familiar with CherryPy, so I can only suggest you look for an Apache module for CherryPy.

Edit: This looks promising: http://tools.cherrypy.org/wiki/BehindApache

Alternatively, to Ishmaeel's correct answer, if you have a server with 2 network cards, you could have each server answer requests on different IP addresses.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top