Forward port 80 and 443 to another droplet via the private network.

August 23, 2015 777 views
Firewall Linux Commands Networking Ubuntu

I happened to accidentally remove my old iptables for forwarding port 80 and 443 to another droplet on the private DO network. After googling now for a few hours I have to say I really can't find anything related to it. From what I remember I read a tutorial here but as said I can't find it. Maybe someone could tell me how to do it or link me to the tutorial (if it still exists).

Many thanks,

1 Answer

Okay so apparently I had the same script on another server (for whatever reason. Well I won't complain...)


echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -F
iptables -t nat -F
iptables -X

iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination
iptables -t nat -A POSTROUTING -p tcp -d --dport 443 -j SNAT --to-source

The same for port 80 and so on...

Have another answer? Share your knowledge.