How to configure Nginx with Let's Encrypt on CentOS 8

‮//:sptth‬www.lautturi.com
How to configure Nginx with Let's Encrypt on CentOS 8

To configure Nginx with Let's Encrypt on CentOS 8, you will need to install the certbot tool and the python3-certbot-nginx package.

  1. First, install certbot and python3-certbot-nginx by running the following command:
sudo dnf install certbot python3-certbot-nginx
  1. Next, stop the Nginx service and disable it from starting at boot time:
sudo systemctl stop nginx
sudo systemctl disable nginx
  1. Run the certbot command to obtain a SSL certificate and configure Nginx to use it:
sudo certbot --nginx -d example.com -d www.example.com

Replace example.com and www.example.com with the domains you want to secure with SSL.

  1. The certbot tool will prompt you to select an email address and agree to the terms of service. It will then attempt to obtain an SSL certificate and configure Nginx to use it. If successful, it will also update the Nginx configuration to redirect all HTTP traffic to HTTPS.

  2. After the certificate is obtained and the Nginx configuration is updated, start the Nginx service and enable it to start at boot time:

sudo systemctl start nginx
sudo systemctl enable nginx

Your Nginx server should now be configured to use SSL with Let's Encrypt.

Remember to renew the SSL certificate before it expires. You can automate this process by using the certbotrenew command, which can be run as a cron job.

Created Time:2017-10-16 14:38:45  Author:lautturi