Thursday, August 19, 2010

Single external IP address to multiple web servers on multiple machines?

I have a single IP address coming into a netgear router. Although I can single port forward to any machine, I want to route to each machine depending on the website being serviced, i.e. df1.digital-fortress.co.uk --%26gt; 92.168.1.10 df2.digital-fortress.co.uk --%26gt; 192.168.1.20 both on port 80. One machine is running apache Fedora 5, the other is on IIS on a windows 2003.





Any help would be appreciated.

Single external IP address to multiple web servers on multiple machines?
When you are NAT'ing using a single IP addresas, the only thing you can do is port-forward. For example, lets say your external IP is 10.10.10.1 (let's pretend it's valid eventhough it's not), you may be able to have your router do PAT (port-address-translation) or port-forwarding by telling it to send all incoming port-80 sessions to a specific web-server.





The problem is that you have multiple web-servers, so you can only do port forwarding for one machine on port 80. Another option is to run one of the sites on port 8080 (or something different than 80), and do port forwarding on that particlar port.





Ultimately, here are you're two hurdles:





(1) Your router/switch may not support PAT.


(2) If it does, you only have 1 public external IP address and two distinct internal servers behind it.





Your realy solution is to make sure that you do PAT (or get hardware that will support it), and to get a 2nd IP from your ISP.
Reply:You have to change the access port for each web server. Because if I browse to EXAMPLE - 123.45.67.89, by default, which server will it go to? Which ever one is listening on port 80. If they are listening on port 80, then which one are you forwarding to. You'll have to give the web servers each a different listening port. So one would be 123.45.67.89:81, 123.45.67.89:82, etc. FYI, replace the IP with names, but add :port number to the end to go to a different port.





Good luck.
Reply:you need a to be running local named and bind daemons.





set your bind to forward subdomains to certain folders.





bind manpages explain it pretty well.
Reply:You can set up the router to send to the MAC address of the individual machines. Doesn't the router do that for you automatically. Is it not that you want to route it but that you want to restrict the routing to the specific machines? That can be done in the route by setting up specific routing tables. It can also be done on the individual machines. Look at the command "Route add ....." The help for that command will tell you the format of the command.
Reply:I'm not sure that can be done. The router only knows the IP and port you are requesting. There may be a way in DNS to map the URL to a URL/port combination but I don't think so.





I accomplished the task by using distinct IPs for each sub-domain. I also have different routers which handle the requests.





Edit: Given your updated information, you should be able to use a distinct top level path on the web server so that if you access /abc it will be directed to a specific machine. I don't think the router will do this but you could have your primary web server do it for you. Then you could use the path they attempt to access for the redirection.





When the ip contact is made the textual name of the domain is not passed as part of the message in the TCP/UDP stream. That's why I don't think the router can make any distinction. Come to think of it... if you map a sub-domain to a virtual directory on your main server, you could probably redirect it with that information. It is an interesting question. I have not ever tried it with virtual directories before.
Reply:you cant route over the internet with a local private IP address .. im presuming when you said 92.168 ...you really meant 192.168.x.x


No comments:

Post a Comment