I have nginx running on port 80 and apache running on port 8080
I want to transfer all the traffic to both nginx and apache asynchronously i.e the performance of one server wont be dependent on the others. The reason being nginx will serve my website and apache will be used to run analytics on the traffic.
I tried the solution mentioned in the question below
sudo iptables -A PREROUTING -t mangle -p tcp ! -s 127.0.0.1/32 --dport 80 -j TEE --gateway 127.0.0.1
sudo iptables -A POSTROUTING -t nat -p tcp -s 127.0.0.1/32 --dport 8080 -j SNAT --to 127.0.0.1:8080
The solution mentions using DNAT with POSTROUTING on NAT table but it is not allowed to do that. DNAT is only allowed on PREROUTING/OUTPUT.
I am using iptables v1.4.10 on ubuntu 11.04