How to Open a Web Server Port on CentOS

The web server on VPS requires port settings to provide access to the web. The port required to be opened on iptables is port 80 (http) and port 443 (https). There are two ways to set this:

 

  1. By editing on /etc/sysconfig/iptables/ as on the following command:
    • First, please type the command 
    • Next, please edit in the given bold line

:IN_public_deny - [0:0]

:IN_public_log - [0:0]

:OUTPUT_direct - [0:0]

-A INPUT -p udp -m udp --dport 10050 -j ACCEPT

-A INPUT -p udp -m udp --dport 10050 -j ACCEPT

-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT

-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT

-A INPUT -m connectrack --ctstate RELATED,ESTABLISHED -j ACCEPT

-A INPUT -i lo -j ACCEPT

-A INPUT -j INPUT_direct

-A INPUT -j INPUT_ZONES_SOURCE

-A INPUT -j INPUT_ZONES

  • If it works, it'll produce something like this:

  1. Opening port by typing command
    • You can also use the commad at the terminal with the following commands 

iptables -A INPUT -p tcp -m tcp ▪dport 443 -j ACCEPT

iptables -I INPUT -m state --state ESTABLISHED,RATED -j ACCEPT

 

  • Next, save the iptables changes with the command

Service iptables save

  • If it manages to save then it will produce something like this :

  • Then, please do a set iptables check with command

iptables -nvL\

  • If successful it will show like this :

  • If so, please do a check by opening the web which is placed on the server via browser
How to Log In to a Server via SSH on Linux and macOS
What Is Pay-As-You-Use?