what I want to do is to redirect web traffic in this way:
Every request to port 80 that HTTP GETs a given address should be redirected to a particular port (4444).
Every other request goes to port 80.
Since I can't do it by using web proxy modules and / or forwarding for various reasons, I'm looking for a way to do it with iptables. Inspired by this article, i used this rule for my iptables:
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 \ -m string --algo bm --string 'GET /mjpegcgi.cgi' \ -j REDIRECT --to-port 4444
Then I opened two netcat processes listening on 4444 and 80. However, when I try to test the rule with:
wget -qO- http://192.168.1.88/mjpegcgi.cgi
What I have is always response from port 80 only. What am I doing wrong?