Secure http with Certbot

The procedure to secure the website with SSL encryption is well documented in the DigitalOcean tutorial.

Requirements

Make sure you have:

  1. DNS-records for both webdomain.com and www.webdomain.com.
  2. server_name website.com www.website.com; included in your NGINX server block.

Get SSL certificate

With verything in place, Certbot will provide an SSL certificate through an nginx plugin, that will take care of reconfiguring the server block and reloading the config. The first command below will run the plugin, the second will check for automatic renewal of all your certificates.

$ sudo certbot --nginx -d webdomain.com -d www.webdomain.com
$ sudo certbot renew --dry-run