Public API for Service Management

How to Setup Let’s Encrypt SSL with Nginx on CentOS 8

Joe Harris
November 26, 2020

In this tutorial we will show you how to provide an encrypted HTTPS connection for our site on the Nginx web server using a free Let’s Encrypt SSL certificate. Necessary conditions:

  • Domain name;
  • CentOS 8 server with public IP that appears in the DNS A record of your domain name;
  • Installed Nginx web server.

Installing and configuring snapd

It is better to use snapd to install and maintain Certbot. This way, it will always be updated, and automatic certificate renewal will be pre-configured. To install snapd, use the following commands:

dnf install epel-release; dnf install snapd

Enable and start snapd.

systemctl enable --now snapd.socket

Enable classic snap support.

ln -s /var/lib/snapd/snap /snap

Now reboot the system.


Check if the latest version of snapd is installed.

snap install core; snap refresh core

Installing the Certbot package

Before installing the Certbot package from snap, you must be sure that there is no other Certbot installed on the system.

dnf remove certbot

Now, install Certbot from snap.

snap install --classic certbot

Run the following command to make sure that Certbot will start.

ln -s /snap/bin/certbot /usr/bin/certbot

Automatic obtaining and installation of Let’s Encrypt SSL certificate on Nginx

We recommend configuring the Nginx virtual host by adding its configuration to the /etc/nginx/conf.d/ folder with the .conf extension. If this is not done, the HTTPS configuration for the domain will be added to the nginx.conf file. Execute the next command to begin the certificate acquisition process and follow the instructions.

certbot --nginx

After the process completes successfully, restart Nginx.

systemctl restart nginx

Redirect from HTTP to HTTPS is configured automatically. Now you can check the result by accessing the domain name in the address bar of your browser.

Automatic SSL certificate renewal

Automatic renewal of the SSL certificate is configured during the installation of Certbot from snap. You can check if the timer is running using this command:

systemctl list-timers | grep certbot

If there is no output, try these locations:

cat /etc/crontab
cat /etc/cron.*/*

You can also run a test run of auto-renewing your certificates:

certbot renew --dry-run

Start Your Cloud Journey Migration made simplified. Take the first step right now.
We use cookies to provide our services and for analytics and marketing. To find out more about our use of cookies, please see our Privacy Policy. By continuing to browse our website, you agree to our use of cookies.