This is how I set up the subdomain for hosting this site (notes.nowacki.org). I already had nginx and letsencrypt set up for the primary website and a few others, but it’s an uncommon-enough exercise for me that I’m writing the notes down here.
/var/www/notes.nowacki.org/htdocs
./etc/nginx/sites-available/nowacki.org
(in my case) and add a block likeserver {
listen 80;
server_name notes.nowacki.org;
root /var/www/notes.nowacki.org/htdocs;
index index.html index.htm;
}
Head over to your domain registrar or DNS provider (I use Gandi) and add the subdomain so it points at your server. This varies with registrar, but you want to create an A record that points your subdomain to your server’s IP address.
Restart nginx by executing sudo systemctl restart nginx
if using an Ubuntu-like system.
At this point you should have a working website over plain old HTTP.
sudo certbot --nginx -d notes.nowacki.org