How can we help?

How to change a default port on web-server



Due to the fact that some of our internal scripts rely on ports 80/443, we strongly disadvise changing the default port configuration on Apache2.

If you want to configure a non-standard port, we recommend keeping default Apache configuration and setup iptables rule to forward local traffic from incoming port e.g 8080 to local 80/443. This will both make you able to access the new port, and our scripts to work correctly.


Example of forwarding incoming traffic from 8080 to port 80:

iptables -t nat -A PREROUTING -p tcp --dport 8080 -j REDIRECT --to-port 80
touch /etc/iptables/rules.v4
/sbin/iptables-save > /etc/iptables/rules.v4


Was this article helpful?
0 out of 0 found this helpful