Certbot Fails Domain Authentication

Viewed 863

I am stumped. I have 2 different domains that I'm trying to install an SSL cert for with Certbot on a Digital Ocean Ubuntu server. Here is the final command I run to obtain the SSL cert:

sudo certbot --nginx -d mydomain1.com -d www.mydomain1.com

I run the exact same command for mydomain1.com and mydomain2.com

Here's what makes no sense. Authentication passes for mydomain1.com but FAILS for mydomain2.com

I'm using identical Nginx Server block config files for both domains. Yes, this includes the root filepath and the server names being identical in the Nginx config file for both.

I have both the config files set to the following:

listen 80;
listen [::]:80;

root /var/www/mydomain2.com;

index index.html index.htm index.nginx-debian.html;

server_name mydomain2.com www.mydomain2.com;

Yes, both config files (for mydomain1.com and mydomain2.com are set to root path of mydomain2.com and server name of mydomain2.com because I need Nginx to serve up the exact same content that I have in that directory. My intention for this was to have mydomain1.com redirect to mydomain2.com but it appears it doesn't work like that which is a separate problem. Right now I'm just trying to validate the SSL cert for mydomain2.com then I'll figure out the redirect.

Thank you in advance for your help.

1 Answers

If I understood the problem correctly, the answer is as follows:

certbot certonly --standalone --preferred-challenges http -d domain1.com -d www.domain1.com

You do not need to modify the nginx default.conf file. use the following method instead.

nano /etc/nginx/sites_available/domain1.com

server {
        listen 80;
        listen [::]:80;
        server_name domain1.com www.domain1.com;
        return 301 https://domain1.com\$request_uri;
}
server {
        listen 443 ssl;
        server_name domain1.com;
        ssl_certificate /etc/letsencrypt/live/domain1.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/domain1.com/privkey.pem;
}

sites enabled symbolic link

ln -s /etc/nginx/sites-available/domain1.conf /etc/nginx/sites-enabled

The same in domain2.com

Related