nginx with SSL (LetsEncrypt) on Ubuntu

First. install prerequisites:

apt install certbot python3-certbot-nginx
Change:
server_name example.com www.example.com;
in the /etc/nginx/sites-available/example.com

Obtain SSL certificate:
certbot --nginx -d example.com -d www.example.com