I have 2 machines and a router running DD-WRT. My machines are,
- Windows 2008, running my DNS and IIS7
- Ubuntu 11.4 Server, running Apache 2.
Currently I have all requests to my external IP address on port 80 forward to my Windows 2008 machine. I have added the additional Ubuntu server recently, and I would like to route the to the IP address based on the host. Currently there is only a 1 to 1 relationship between the port and the server, with all requests for port 80 going to the Windows 2008 machine. As an example, this is what I would want to do:
If I had a request come into my router for example-a.com
, I would forward it to 192.168.1.2
.
If I had a request for example-b.com', I would forward it to
192.168.1.3`
Is this something that needs to be routed through my 2008 machine first, or can I do this from the router?
for this functionality you require a reverse proxy, if you are using apache on your ubuntu server or nginx this is reasonably easy to achieve with minimal extra work
in a nutshell what you would do is set your router port forwarding to your ubuntu server, then setup the webserver to listen for both example-a.com and example-b.com
assuming example-a.com is on the windows server you would then setup example-a.com on the ubuntu server to reverse proxy to your windows server
for apache this looks something like this:
1 - make sure the following lines are in your apache2.conf file and uncommented:
2- create a vhost for example-a.com: and add the following to it:
3- restart apache on your ubuntu server
this will allow you to proxy to the windows server replace internalexaple-a.com with either an IP that example-a.com responds on the win server or an internal dns name that is pointing to the same site on the windows server
I don't believe the router will ever see the host name. DNS is resolved by the client before it sends the request. So the Destination IP will be set in the request and routers route based on Dest IP.
The reason this works for web servers is because HTTP protocol includes the host name int he HTTP request (called a host header), but that's deep in the packet and not something the router sees.
It may help us to know what application/protocol you' need to do this with. HTTP? SSH?
FWIW, I do this with SSH by specify two different ports. Requests for one server go to port 22 and the other to port 29. YMMV