I have three servers. The first is a for my front the two other http server : for dispatch.

I want for example, do : receive a request on my front (public) : site1.com an redirect the request on server1 (private) receive a request on my front (public) : site2.com an redirect the request on server2 (private)

idem for ftp : ftp.site1.com redirect on server1 ftp.site2.com redirect on server2

possible ?

link|improve this question
1  
You really ought to use a proper load balancer for this, not iptables. – ErikA Jul 18 '11 at 15:02
I'm sorry I don't understand your question properly. I think editing DNS records would do the wanted behaviour. I may be rude but my advice would be to read this: wikihow.com/Use-English-Punctuation-Correctly – SamKrieg Jul 18 '11 at 15:04
It is possible that he actually wants only the front server to have DNS records and the other 2 servers just acting as backend servers. This happens more. – Goez Jul 18 '11 at 15:08
Since iptables doesn't understand http protocol, it won't work properly. You need apache + mod_proxy or another reverse proxy (haproxy, nginx). – ghm1014 Jul 18 '11 at 21:49
feedback

1 Answer

yes, it is possible:

# Enable routing.
echo 1 > /proc/sys/net/ipv4/ip_forward 
iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 21 -j DNAT --to-destination xxx.xxx.xxx.xx:21

this will forward packets to ip xxx.xxx.xxx.xxx on port 21. u can leave the :$IPTABLES -t nat -A PREROUTING -p tcp -i eth0 --dport $port -j DNAT --to-destination

For http requests I would suggest mod_proxy instead of iptables.

link|improve this answer
yes but... it s for all packed ... i want for one site transfert packed on one server, and if it s the second website, redirect on the other server. – fred Jul 22 '11 at 12:29
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.