Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
109
rated 0 times [  109] [ 0]  / answers: 1 / hits: 276939  / 3 Years ago, sun, august 15, 2021, 4:26:00

I redirected traffic for port 80 to 8080 on my machine with



sudo iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-ports 8080


It works fine for all the world except my own machine. I am a developer and I need to redirect port 80 to 8080 for myself.



My IP is 192.168.0.111



My web server runs on port 8080



I wish to open website from http://192.168.0.111/ instead of http://192.168.0.111:8080/ from same machine where server runs.


More From » iptables

 Answers
5

You need to use the OUTPUT chain as the packets meant for the loopback interface do not pass via the PREROUTING chain. The following should work; run as root:



iptables -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 8080

[#26146] Monday, August 16, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tubequ

Total Points: 11
Total Questions: 113
Total Answers: 115

Location: Equatorial Guinea
Member since Thu, Oct 7, 2021
3 Years ago
;