Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

Possible Duplicate:
Running two services on port 80

I have a QNAP TS-459 Pro II that comes with an Apache webserver which runs on port 80.

I'd also like to run a small Sinatra app; also on port 80.

I'd like Apache to serve up and, but I'd like Sinatra to serve up

Is it possible to have both webservers running on the same port but only answer based on specific domain binding?

share|improve this question

marked as duplicate by Shane Madden, mailq, Ward, Scott Pack, MDMarra Nov 17 '11 at 1:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Sure, both can use port 80 (on different interfaces.) – Aaron Copley Sep 19 '11 at 21:09
@Aaron don't even need two different physical interfaces. Subinterfaces are fine, as long as you have two IP's to run them on. – Matthew Scharley Sep 19 '11 at 21:11
Yep - Virtual or physical, an interface is an interface. – Aaron Copley Sep 20 '11 at 19:52

No, not unless you have two different public IP's on the server which each server can bind to. Each server then needs to explicitly listen on a specific IP/port combination and it will 'just work'.

The normal solution here if you only have access to a single IP address is to set up your Sinatra server on a different port (localhost:808* is popular), and then use mod_proxy in Apache to manage your Sinatra servers domain internally.

share|improve this answer
can you provide a mod_proxy example? If so, I will mark this answer as accepted. – macek Oct 4 '11 at 18:26
@macek: Personally we use nginx as the proxy and main webserver so I don't have one on hand. The Apache docs are really good though, you're looking to implement a reverse proxy: – Matthew Scharley Oct 4 '11 at 20:08

Only one app can have a particular port/IP combination open at a time , but you can approximate what you want by setting Apache up as a reverse proxy.

The highlights -

  • Run Apache on port 80, and enable mod_proxy
  • Do NOT turn on ProxyRequests (this is for forward proxying only)
  • Run your other app on a different port and/or IP
  • Use Apache virtual hosts and reverse proxy configuration to direct traffic to the appropriate site.

You can see these links for more info -

ApacheTutor article

Apache mod_proxy documentation

share|improve this answer

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