🔔 🔔 🔔 Duyuru: 24. Yılımıza özel indirimler sizleri bekliyor ! Kampanya Kodu : TDATA2024 | Detaylı bilgi için tıklayınız.

How to Redirect HTTP traffic to another IP using iptables


How to Redirect HTTP traffic to another IP using iptables


How to Redirect HTTP traffic to another IP using iptables

I want to redirect all traffic coming to the old server’s http port(during the TTL change period) to the webserver running in new server with a different ip .

DETAILS:

Service : Apache(port 80 and 443)
Interface name in old server(this is a vps) : venet0
Destination ip : 198.89.54.263

SOLUTION:

Use iptables nat to redirect http and https traffic to another server ip and port. Execute the following commands in the source server.

iptables -t nat -A PREROUTING -i venet0 -p tcp –dport 80 -m conntrack –ctstate NEW -j DNAT –to 98.59.254.163:80
iptables -t nat -A PREROUTING -i venet0 -p tcp –dport 443 -m conntrack –ctstate NEW -j DNAT –to 98.59.254.163:443
iptables -t nat -A PREROUTING -m conntrack –ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A POSTROUTING -t nat -j MASQUERADE
Bu cevap yeterince yardımcı oldu mu?

Diğer Dökümanlar