To configure Nginx with Let's Encrypt on CentOS 8, you will need to install the certbot
tool and the python3-certbot-nginx
package.
certbot
and python3-certbot-nginx
by running the following command:sudo dnf install certbot python3-certbot-nginx
sudo systemctl stop nginx sudo systemctl disable nginx
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.
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.
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 certbot
renew
command, which can be run as a cron job.