ubuntusslnginxubuntu-18.04vps

Unable to add Let's encrypt ssl certificate to domains using nginx (certbot)


I have an issue with applying Let's Encrypt SSL certificates to my domains using nginx and certbot. My (Nuxtjs) website is running on a VPS with Ubuntu 18.04. I want to add the certificates to mydomain.nl and staging.mydomain.nl but am unable. I am quite new to this but I did manage to do this before without any problems.

If I am correct the certbot tries to places a file to validate the domain when running sudo certbot --nginx. But then I get the following error:

Failed authorization procedure. mydomain.nl (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://mydomain.nl/.well-known/acme-challenge/PBjT0nQy7m5_bE42I1jr5mMaYxLMma4ONP9FAUgCD3c [2a02:2268:ffff:ffff::4]: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p"
IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: mydomain.nl
   Type:   unauthorized
   Detail: Invalid response from
   http://mydomain.nl/.well-known/acme-challenge/PBjT0nQy7m5_bE42I1jr5mMaYxLMma4ONP9FAUgCD3c
   [2a02:2268:ffff:ffff::4]: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD
   HTML 2.0//EN\">\n<html><head>\n<title>404 Not
   Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p"

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A/AAAA record(s) for that domain
   contain(s) the right IP address.

I have tried adding this block in the config as wel:

location ~ /.well-know/acme-challenge {
    allow all;
    root /var/www/mydomain.nl/html;
}

But no success. I can visit my websites on my domains so the DNS should be correct.


Solution

  • Your domain registrar has pre-configured an AAAA record for your domain. Remove AAAA record from your DNS-settings. In your case, remove "wwww.mydomain.nl AAAA 2a02:2268:ffff:ffff::4" record.

    aaaa-record-example