AlmaLinux / Rocky Linux 8 Open HTTP/HTTPS Port 80/443 with Firewalld
In today’s interconnected digital landscape, properly configuring your web server’s firewall settings is crucial for both security and functionality. Whether you’re setting up a new web server or maintaining an existing one, understanding how to manage HTTP (port 80) and HTTPS (port 443) access through firewalld on AlmaLinux or Rocky Linux 8 is an essential skill for system administrators.
As RHEL-compatible distributions, both AlmaLinux and Rocky Linux 8 come with `firewalld` as their default firewall management tool. This powerful firewall solution helps protect your server while allowing necessary services to function smoothly. However, for your web server to be accessible to the outside world, you’ll need to explicitly configure these ports.
Whether you’re a seasoned system administrator or just getting started with Linux server management, this tutorial will help you secure your web server while maintaining its accessibility.
FirewallD includes the default firewall application in these Linux results to follow the commands mentioned below if you have it:
sudo dnf install firewalld
sudo systemctl start firewalld
sudo systemctl enable firewalld
sudo systemctl status firewalld
This tutorial will help you to learn:
- Steps to open HTTP port 80 and HTTPS port 443 for all time
- Steps to follow the command to open or close any server and port in AlmaLinux
Check Commands to open or close HTTP port 80 & HTTPS 443 on AlmaLinux/ Rocky 8
Step 1: Monitor the running AlmaLinux port list: Before opening the port, it’s necessary to monitor what are ports & services are using before to communicate outside the public network in our firewall. To access this use:
sudo firewall-cmd --list-all
Or
netstat -na | grep port-number
Now, you have to replace the port number with the one you want to identify. In case the port is non-active then you are not able to get the results in return.
Step 2: Command to Open port 80 and port 443: It is universal that firewall includes some default pre-configured services and http & https as well. Therefore, we can either include the service command or port command of the firewalld to permit them in the public zone:
sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --zone=public --permanent --add-service=https
However, if Apache web server’s application is running on some other port apart from 80 & 443 then we can open that also. Let’s assume your web application is running on some custom port 5000. Thus, to access it we can use it:
sudo firewall-cmd --zone=public --permanent --add-port 5000/tcp
You have to replace 5000 with your wish port number which you want to open
Step 3: Reload Firewalld service- Just make sure that open service or port successfully match to the firewalld, reload its services by this command –
sudo firewall-cmd –reload
(optional) Close or block port 80 and 443 – After some time or in some case, you want to block or close the HTTP and HTTPS services or any other port then you can do it, manually, using below the syntax:
sudo firewall-cmd --zone=public --permanent --remove-service=http
sudo firewall-cmd --zone=public --permanent --remove-service=https
For some particular port number
sudo firewall-cmd --zone=public --permanent --remove-port 5000/tcp
For Reloading the firewall –
firewall-cmd –reload
Conclusion:
To open HTTP and HTTPS ports 80 and 443 on AlmaLinux or Rocky Linux 8 using Firewalld, one must configure the firewall settings to allow traffic through these essential ports, thereby enabling web services to function properly. This process is crucial for ensuring that web applications are accessible over the internet.