How do I add a second domain in a file with an SSL certificate already signed by Let's Encrypt?

Xirup@lemmy.one to Selfhosted@lemmy.world – 1 points –

Well, at this moment thanks to this tutorial I managed to configure Nginx correctly and now when I go to the subdomain of my website, everything works perfectly.

What the tutorial does not mention is how I can add a second domain in the /etc/nginx/sites-enabled/mydomain file since at the end of the tutorial the document already has an SSL certificate that points to a specific IP address and domain.

I have read that it is as simple as "copy and paste below the "server" block but in that specific example there are two server blocks, and if I try to create another file using the same content of that one but changing the IP and subdomain, I get an error when trying to restart Nginx saying there can't be two files pointing to ::[80]:

5

Run the certbot client again and this time specify all the domains you want to be part of one certificate.

I hadn't thought of it and it sounds awkwardly simple, I'll try it.