I want to run a simple python webserver on my ubuntu linode with the following command (it simply puts the current dir up on the port specified)
python -m SimpleHTTPServer 8080
I am using port 8080 to avoid using sudo to run on port 80
To make it accessible I redirect port 80 to port 8080 with the following command:
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
Now any computer can access my website giuliopizzini.com EXCEPT localhost which gets a socket error, connection refused. If I point localhost to giuliopizzini.com:8080 it works OK but the redirect fails.
I have firewall enabled but if I reset it with
sudo iptables -F
the behavior is exactly the same, so that does not seem to play a role here.
How can I make the redirect work on localhost as well?