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 example.com
and foo.example.com
, but I'd like Sinatra to serve up bar.exapmle.com
.
Is it possible to have both webservers running on the same port but only answer based on specific domain binding?
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 -
You can see these links for more info -
ApacheTutor article
Apache mod_proxy documentation
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 usemod_proxy
in Apache to manage your Sinatra servers domain internally.