My VM has set some rules for access to a web server and a SSH. The server is running in the internal port 8080 en redirected using iptables to the port 80 with the command:
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
When i add the rule to DROP INPUT and afterwards the one for oppening the port
IPTABLES -A INPUT -p tcp --dport 80 -j ACCEPT
it doesnt work.
I have the same setup on port 4422 for the SSH server and works perfectly but not in the http one.
IPTABLES --LIST:
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:4422
ACCEPT all -- anywhere anywhere(this one is for the lo)
ACCEPT tcp -- anywhere anywhere tcp dpt:http