How to Setup Free SSL for Nginx on Ubuntu

1. Login to the server using SSH

SSH to the server as a sudo user

2. Install Snapd

For the lunix distributions without snapd installed, install using the folliwing command

$ sudo apt update
$ sudo apt install snapd

If the sudo command isn’t installed (usually because a root password was provided at install time), you can install snap by first switching to the root account:

$ su root
$ sudo -i

Either log out and back in again, or restart your system, to ensure snap’s paths are updated correctly.

After this, install the core snap in order to get the latest snapd.

$ sudo snap install core
core 16-2.45.2 from Canonical✓ installed

3. Check if you have latest version of your snapd 

sudo snap install core; sudo snap refresh core

4. Install Certbot and prepare certbot command

sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot

5. Install Certificate

if you want certbot to edit the nginx confi automaticaly and enalbe ssl for you in a single step uyse the following command

sudo certbot --nginx

Or if you are willing to update the config manualy and only need to generate the certificate, use the following command

sudo certbot certonly --nginx

6. Test Renewal 

The Certbot packages on your system come with a cron job or systemd timer that will renew your certificates automatically before they expire. You will not need to run Certbot again, unless you change your configuration. You can test automatic renewal for your certificates by running this command:

sudo certbot renew --dry-run

The command to renew certbot is installed in one of the following locations:

/etc/crontab/

/etc/cron.*/*

systemctl list-timers

7. Check if the SSL is installed

To confirm that your site is set up properly, visit https://yourwebsite.com/ in your browser and look for the lock icon in the URL bar.

 

 

 

 

How to Setup Free SSL for Nginx on Ubuntu
Scroll to top