Here’s a simple nat rule for iptables that will route incoming web traffic to your varnish cache. This allows you to implement varnish without reconfiguring apache. In the varnish config, set the backing do be 127.0.0.1:80.
1 2 3 |
iptables -D PREROUTING -s ! 127.0.0.1 -d 192.168.100.16 \ -p tcp -m tcp --dport 80 -j DNAT \ --to-destination 192.168.100.16:6081 -t nat |
Here’s a different rule that also seems to work:
1 2 3 |
/sbin/iptables -t nat -A PREROUTING \ -i eth0 -d 46.105.124.96 -p tcp -m tcp \ --dport 80 -j REDIRECT 6081 |