Group: comp.os.linux.networking
From: Nicolas BOUTHORS
Date: Monday, March 17, 2008 1:24 PM
Subject: Re: Port forwarding question

Bubba a écrit :
> There are 3 servers currently running, all 3 with up and running web
> servers (apache, apache2 and IIS). How can I direct traffic from the
> Internet to the web server that is not on gateway, but in the local
> network? In addition, how can enable users from the internet to use
> *all* 3 web servers at their discretion (for example, when user writes
> www.mydomain.net/server1 - IIS on local IP x.x.x.y server pops out,
> www.mydomain.net/server2 -apache2 server on local IP x.x.x.z pops out,
> etc...)?

If you want to do it based on the URL, then you need to use Apache on
the gateway with mod_rewrite. Something like this :

RewriteEngine on
RewriteRule /server1/(.*) http://10.1.2.3/$1 [proxy,qsappend,last]
RewriteRule /server2/(.*) http://10.1.2.4/$1 [proxy,qsappend,last]
RewriteRule /server3/(.*) http://10.1.2.5/$1 [proxy,qsappend,last]

If you want to do it with iptables/netfilter then you could do something
like this :

iptables -t nat -A PREROUTING -p tcp --dport 8080 -j DNAT --to 10.1.2.3:80
iptables -t nat -A PREROUTING -p tcp --dport 8081 -j DNAT --to 10.1.2.4:80
iptables -t nat -A PREROUTING -p tcp --dport 8082 -j DNAT --to 10.1.2.5:80

Cheers,

Nico


--
Nicolas Bouthors -=- Tel : 06 20 71 62 34 -=- Fax : 01 46 87 21 99
NBi SARL -=- http://nbi.fr -=- nbouthors@nbi.fr

Safety Articles | Usenet Groups | Usenet News | Bluegrass