0

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.

And as requested, when i run ls -ld /var/www/mydomain.nl/html i get the following output:

drwxrwxr-x 10 kim kim 4096 May 13 20:38 /var/www/mydomain.nl/html

The Nginx user is www-data ?

Can anybody point me in the right direction here? Any help would be much appreciated!

Thanks in advance!

2
  • 2
    First, correct the typo in the nginx config block at the end of your post, and restart nginx. Second, edit your post to include the output of ls -ld /var/www/mydomain.nl/html and also edit the post to show what user ID nginx is running as, and also what user CertBot runs as.
    – Jim L.
    May 13, 2020 at 21:00
  • That should be location ^~ /.well-known/acme-challenge May 14, 2020 at 8:39

2 Answers 2

0

This happens because Certbot verifies that the website domain is online. If this receives a http response with 404 code, you will not be able to verify that it exists and the certificate will not be generated.

You could try the standalone mode.

certbot certonly --standalone --preferred-challenges http -d example.com --webroot-path /path/to/root

0

Turned out my domain registrar pre-configured an AAAA record for my domain. I had to remove this record for things to work. Thanks for thinking along!

Not the answer you're looking for? Browse other questions tagged .