certbot code example

Example 1: nginx certbot ubuntu

// Ubuntu 20.04
sudo apt install certbot python3-certbot-nginx

// Ubuntu 18.04
sudo add-apt-repository ppa:certbot/certbot
sudo apt install python-certbot-nginx

// Configure ufw
sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'
sudo ufw delete allow 'Nginx HTTPS'

sudo certbot --nginx -d example.com

Example 2: ubuntu certbot nginx

sudo add-apt-repository ppa:certbot/certbot
sudo apt install python-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com

Example 3: certbot configure

certbot certonly --webroot -w /var/www/html -d www.theflock.de -d theflock.de

Example 4: certbot command

certbot certonly --webroot -w /var/www/example -d www.example.com -d example.com -w /var/www/other -d other.example.net -d another.other.example.net

Example 5: certbot

sudo snap install --classic certbot

Example 6: how to get free ssl certificate from letsencrypt for local

openssl req -x509 -out localhost.crt -keyout localhost.key \
  -newkey rsa:2048 -nodes -sha256 \
  -subj '/CN=localhost' -extensions EXT -config <( \
   printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")