Port 80 is the standard port number used in TCP/IP networks for HTTP communication. HTTP, the HyperText Transfer Protocol, is the most common protocol between web browsers and web servers, and it typically transmits data through port 80.
On Linux systems, you can use the netstat command to check port status:
netstat -anp | grep 80
If the output shows something like this, it means port 80 is currently in use:
tcp 0 0 :::80 :::* LISTEN 23440/apache2
Apache is a commonly used web server software. Changing its configuration file allows you to modify the listening port.
Open the /etc/apache2/ports.conf file with a text editor, find the line Listen 80, and change 80 to an unused port number such as Listen 8080.
Save and close the file, then restart Apache by running:
sudo service apache2 restart
After that, Apache will listen on the new port.
iptables is a Linux tool for managing network traffic, and it can forward requests from port 80 to another port to achieve port changes.
Open the iptables configuration file:
sudo nano /etc/sysconfig/iptables
Find the following line:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
Add this line after it:
-A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-port 8080
Where 8080 is the port you want to redirect to.
Save the file and restart iptables:
sudo service iptables restart
Now, all traffic coming to port 80 will be redirected to the new port.