Skip to content

Instantly share code, notes, and snippets.

@jsheridanwells
Created February 9, 2018 14:09
Show Gist options
  • Save jsheridanwells/18bb9389d9357910c211bf9965698520 to your computer and use it in GitHub Desktop.
Save jsheridanwells/18bb9389d9357910c211bf9965698520 to your computer and use it in GitHub Desktop.
Setting up SSL certificates on NGINX server w/ Certbot

Setting UP SSL Certificates on NGINX Server on Ubuntu w/ Certbot

Certbot Docs: https://certbot.eff.org/docs/

Digital Ocean Tutorial: https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04

  1. Install Certbot:
$ sudo add-apt-repository ppa:certbot/certbot
  1. Update package list:
$ sudo apt-get update
  1. Install Certbot Nginx package:
$ sudo apt-get install python-certbot-nginx
  1. Update Nginx config file:
$ sudo nano /etc/nginx/sites-available/default
  1. Find server_name line, replace _ with your doman (simple domain and www domain).
server_name example.com www.example.com;
  1. Verify configuration syntax:
$ sudo nginx -t
  1. Reload Nginx:
$ sudo systemctl reload nginx
  1. Check UFW firewall status:
$ sudo ufw status

(If it is not active, follow these steps to activate).

  1. Update UFW to allow https traffic:
$ sudo ufw allow 'Nginx Full'
$ sudo ufw delete allow 'Nginx HTTP'
  1. Get a Certbot certificate:
$ sudo certbot --nginx -d example.com -d www.example.com

(You may go through a series of prompts, agreements, email signup, etc.

  1. Check your domain with an https call: https://example.com. If it makes secure connection, you're good to go.

  2. Verify Certbot autorenewal:

$ sudo certbot renew --dry-run

Good Job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment