View previous topic :: View next topic |
Author |
Message |
smileaf n00b
Joined: 16 Mar 2005 Posts: 14 Location: USA
|
Posted: Wed Mar 16, 2005 7:14 pm Post subject: hostname based ip routing. |
|
|
I was wondering if there is a way to forward ports to differnet Ips based on the hostname from the request.
for example:
hostname1.com:80 -> 192.168.0.1
hostname2.com:80 -> 192.168.0.2 _________________ This has been leafed. |
|
Back to top |
|
|
msalerno Veteran
Joined: 17 Dec 2002 Posts: 1338 Location: Sweating in South Florida
|
Posted: Wed Mar 16, 2005 7:25 pm Post subject: |
|
|
Off of the top of my head, I would have to say that you cannot do it with iptables. But somebody will probably tell me that I am wrong.
It looks like you want to setup some virtual web servers. If both ip's are on the same box, then you could just use host headers. If the ip's are on different boxes, then you could use host headers along with apache's proxypass directive, if apache.
http://httpd.apache.org/docs-2.0/mod/mod_proxy.html |
|
Back to top |
|
|
smileaf n00b
Joined: 16 Mar 2005 Posts: 14 Location: USA
|
Posted: Thu Mar 17, 2005 4:19 am Post subject: |
|
|
well what I'd like to setup would not only be for different web servers but also for ssh access directly. so an apache proxy wouldn't exactly be ideal. however this brings in an interesting idea.. what can proxy servers do? _________________ This has been leafed. |
|
Back to top |
|
|
Telamon Tux's lil' helper
Joined: 29 Dec 2003 Posts: 129
|
Posted: Thu Mar 17, 2005 4:27 am Post subject: Can't do it for ssh |
|
|
You can't do it for ssh, or most protocols. The reason it works for web is that it the web browser sends the hostname it's connecting to in it's request to the web server. The web server then parses this "host header" field, and loads the correct page for that hostname.
Most other protocols only receive the IP address in the header, and don't have redirection support in the protocol even if they did know the hostname, so the hostname trick won't work for them. You have to either use a second IP address, or use alternate ports.
So you could bind two IPs to the external interface of your gateway, or use alternate ports, but that's pretty much it. If you are just wanting to use ssh, alternate ports is the way to go. You can put a line in your ~/.ssh/config file to save the alternate portso you don't have to specify it on the command line. Like this:
Code: |
Host altone
Hostname <ip address>
Port <port>
HostKeyAlias altone
Host alttwo
Hostname <ip address>
Port <alternate port>
HostKeyAlias alttwo
|
|
|
Back to top |
|
|
|