Skip to content

Instantly share code, notes, and snippets.

@akane10
Last active July 20, 2020 09:03
Show Gist options
  • Save akane10/dcb1047745d9781b42a852967ba4487d to your computer and use it in GitHub Desktop.
Save akane10/dcb1047745d9781b42a852967ba4487d to your computer and use it in GitHub Desktop.
How To Secure Nginx with Let's Encrypt on Ubuntu

Original Source

- Installing Certbot

$ sudo add-apt-repository ppa:certbot/certbot

$ sudo apt install python-certbot-nginx

- Confirming Nginx’s Configuration

$ sudo nano /etc/nginx/sites-available/example.com

change server_name

...
server_name example.com www.example.com;
...

$ sudo nginx -t

$ sudo systemctl reload nginx

- Allowing HTTPS Through the Firewall

$ sudo ufw status

$ sudo ufw allow 'Nginx Full'

$ sudo ufw delete allow 'Nginx HTTP'

$ sudo ufw status

should like this :

Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere
Nginx Full                 ALLOW       Anywhere
OpenSSH (v6)               ALLOW       Anywhere (v6)
Nginx Full (v6)            ALLOW       Anywhere (v6)

- Obtaining an SSL Certificate

$ sudo certbot --nginx -d example.com -d www.example.com

- Verifying Certbot Auto-Renewal

$ sudo certbot renew --dry-run

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