Configure Firewall on Apache/HTTPD RHEL Or CentOS

To allow HTTP and HTTPS traffic through Firewalld on CentOS/RedHat, you can follow these steps:

1. Check the current status of Firewalld by running:

   sudo firewall-cmd --state

If the status is not "running", start Firewalld by running:

   sudo systemctl start firewalld

2. Add HTTP and HTTPS services to Firewalld:

   sudo firewall-cmd --permanent --add-service=http

   sudo firewall-cmd --permanent --add-service=https

These commands will allow HTTP and HTTPS traffic through Firewalld.

3. Reload the Firewalld configuration:

   sudo firewall-cmd --reload

This will apply the new rules and reload the Firewalld configuration.

4. Verify that the HTTP and HTTPS services are now enabled in Firewalld:

   sudo firewall-cmd --list-services

This should list all of the services that are currently allowed through Firewalld. You should see "http" and "https" in the list.


That's it! You should now be able to access your web server using HTTP and HTTPS on CentOS/RedHat.

Here's a step-by-step guide on how to use Certbot to enable HTTPS with Apache on CentOS 8:

1. Install Certbot:

   sudo dnf install certbot python3-certbot-apache

2. Verify that Apache is installed:

   sudo dnf list installed httpd

   If Apache is not installed, install it using the following command:

   sudo dnf install httpd

3. Allow HTTPS traffic through the firewall:

   sudo firewall-cmd --permanent --add-service=https

   sudo firewall-cmd --reload

4. Configure Apache to use HTTPS:

   sudo nano /etc/httpd/conf.d/ssl.conf

   Uncomment the following lines:

   LoadModule ssl_module modules/mod_ssl.so

   Listen 443 https

5. Generate a new SSL/TLS certificate:

   sudo certbot --apache

   Follow the prompts to create a new certificate. When prompted, make sure to select the option to redirect HTTP traffic to HTTPS.

6. Verify that HTTPS is working:

   sudo systemctl restart httpd


Open your web browser and navigate to your website using `https://` in the URL. You should see a lock icon in the address bar, indicating that your website is now using HTTPS.


That's it! Your website should now be using HTTPS with a valid SSL/TLS certificate.