Behold this command:
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
I use that to reroute any incoming traffic from
8080, because the Apache 2 server on that computer runs as an unprivileged user and only root can open well known ports. It is saved in
/etc/iptables/rules.v4 and it works, if I open the web site on a remote computer. The virtual host is bound to
However, if I ssh into that server and open a browser with X11Forwarding active, entering the IP into the address bar won't open the web site, but the connection will time out instead. Only if I add
:8080 to the address it works. So bottom line, the port routing is not working when opened on the same computer.
My question is: How do I need to modify or add a routing directive, so this will work locally as well?