Languages
[Edit]
EN

Linux - iptables redirect port 80 to 8080

6 points
Created by:
Mikolaj
489

Hi, today I would like to show you how to redirect port 80 to 8080 by using iptables command under linux.

In order to do that we need to execute below commands from root user.

sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

After executing above commands we should redirect all traffic from port 80 to 8080.

If we want to redirect traffic to any other port we just need to change port 8080 to any other like 8081.

In case you modify port 8080 it is used in both commands.

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Linux

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join