Home How to use nginx to setup https with certbot and let's encrypt
Post
Cancel

How to use nginx to setup https with certbot and let's encrypt

Install nginx

1
2
3
sudo apt update
sudo apt upgrade -y
sudo apt install nginx -y

press ‘Enter’ if it prompts to restart some program.

Install certbot

I’m in Ubuntu 20.04, so I use snap to install certbot.

certbot official instuctions

1
2
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot

Run certbot

1
sudo certbot --nginx

follow the instructions it prompts you.

If you only enter one domain, and not add server block for it, it will create two new server blocks in your /etc/nginx/sites-enabled/default file, one for port 80, one for port 443.

I will move these two server blocks to /etc/nginx/sites-enabled/yourdomain.com and configure it.

Append new domains

1
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
This post is licensed under CC BY 4.0 by the author.

How to set a simple reverse proxy with nginx

Postgres init setup