'certbot modifies the default nginx config

I am following a mini-tutorial to install letsencrypt certificates. OS is ubuntu 22.04.

I had already installed nginx, and my own example.com config file to /etc/nginx/sites-available

/etc/nginx/sites-available/example.com

I left the /etc/nginx/sites-available/default unchanged.

I removed the pre-installed certbot

sudo apt remove certbot

Then I installed snap and classic certbot:

sudo apt install snapd
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot

Then I ran

sudo nginx -t
sudo systemctl reload nginx

Then I did

sudo certbot --nginx -d example.com

I accept the agreement, entered my email, and hit return.

Instead of modifying /etc/nginx/sites-available/example.com, /etc/nginx/sites-available/default was modified.

What am I doing wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source