Create wildcard SSL with Certbot on Ubuntu Linux for Node.js

sudo apt-get install nginx
sudo apt-get update
sudo apt-get install python3-certbot-nginx

Setup Ngnix

Certbot can automatically configure SSL for Nginx, but it needs to be able to find the correct server block in your config. It does this by looking for a server_name directive that matches the domain you’re requesting a certificate for.

//Allow through Firewall, ufw stands for uncomplicated firewall
sudo ufw allow 'Nginx Full'

Open configuration of Nginx

sudo nano /etc/nginx/sites-available/default

Add the following directive

server {
listen 80;
listen [::]:80;
server_name *.example.com;
return 301 https://$host$request_uri;
}

301 means permanently moved

sever block is chosen by matching host header with server name

listen:80 means the server is listening at port 80 for incoming requests

Then reload Nginx with the following command

sudo systemctl reload nginx

But this won’t auto-renew, u will have to repeat the process (except the Nginx configuration part) every 3 months

How to remove certificates?

When deleting SSL certificates, it’s not about deleting merely one file manually. You would need to go through at least the following directories and delete the files associated with the domain name.

  • /etc/letsencrypt/archive
  • /etc/letsencrypt/live
  • /etc/letsencrypt/renewal

Method 1


#This command will offer an index from which you can select the domain name to delete

Method 2

# Show the list of certificates 
certbot certificates

You will also have to remove SSL directive from

etc/nginx/sites-available/default

Finding Magic.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store