Cerbot challenge failed

So I’m following this guide: https://www.humankode.com/ssl/how-to-set-up-free-ssl-certificates-from-lets-encrypt-using-docker-and-nginx to use certbot inside a docker container. But when using the command below I get the error below. I tried connecting to the docker container and adding a file manually inside /usr/share/nginx/html/.well-known/acme-challenge and was able to access it in my browser. Because of this I think maybe something is wrong with my dns records? but my website is available on the domain name so I’m not sure what exactly.

On one.com I added 2 A records:

celta.be -> server_ip
www.celta.be -> server_ip

My domain is: http://celta.be

I ran this command:

sudo docker run -it --rm \
-v /docker-volumes/etc/letsencrypt:/etc/letsencrypt \
-v /docker-volumes/var/lib/letsencrypt:/var/lib/letsencrypt \
-v /docker/letsencrypt-docker-nginx/src/letsencrypt/letsencrypt-site:/data/letsencrypt \
-v "/docker-volumes/var/log/letsencrypt:/var/log/letsencrypt" \
certbot/certbot \
certonly --webroot \
--register-unsafely-without-email --agree-tos \
--webroot-path=/data/letsencrypt \
--staging \
-d celta.be -d www.celta.be

It produced this output:

Plugins selected: Authenticator webroot, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for celta.be
http-01 challenge for www.celta.be
Using the webroot path /data/letsencrypt for all unmatched domains.
Waiting for verification...
Challenge failed for domain www.celta.be
Challenge failed for domain celta.be
http-01 challenge for www.celta.be
http-01 challenge for celta.be
Cleaning up challenges
Some challenges have failed.

IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: www.celta.be
   Type:   unauthorized
   Detail: Invalid response from
   http://www.celta.be/.well-known/acme-challenge/l_YQt_hsJR7FTYte-W8TaWW5FE3KIZSqw4jBMzmbh-4
   [116.203.228.136]: "<html>\r\n<head><title>404 Not
   Found</title></head>\r\n<body>\r\n<center><h1>404 Not
   Found</h1></center>\r\n<hr><center>nginx/1.17.4</ce"

   Domain: celta.be
   Type:   unauthorized
   Detail: Invalid response from
   http://celta.be/.well-known/acme-challenge/BZHWlYYyVaFiasMrU5HHZ333Lx4h98XJusRiOt87yQ8
   [116.203.228.136]: "<html>\r\n<head><title>404 Not
   Found</title></head>\r\n<body>\r\n<center><h1>404 Not
   Found</h1></center>\r\n<hr><center>nginx/1.17.4</ce"

   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.

My web server is (include version): nginx/1.17.4

The operating system my web server runs on is (include version):
docker os : Debian GNU/Linux 10 (buster)
host os: ubuntu 18.04

My hosting provider, if applicable, is:
dns: one.com
server hetzner.com

I can login to a root shell on my machine (yes or no, or I don’t know): yes

I’m using a control panel to manage my site (no, or provide the name and version of the control panel): no

The version of my client is (e.g. output of certbot --version or certbot-auto --version if you’re using Certbot): certbot 0.31.0

1 Like

I would start by placing a test file in the suspected challenge folder.
Then see if you can actually access that test file form the Internet.
I'm guessing you won't.

[reply with findings and we'll go from there]

Hi, In my answer I stated I already tried this and it worked.
I’ve added a index.html again, you can find it here: http://www.celta.be/.well-known/acme-challenge/

I’m a little bit confused…
What is the path to where you placed the index.html file?
Please also put a simple text file there; like:
[cd to that location then]
echo 'test' > test
Then test it with: http://www.celta.be/.well-known/acme-challenge/test

The path is: /usr/share/nginx/html/.well-known/acme-challenge/
I am also able to download a simple text file like that: http://www.celta.be/.well-known/acme-challenge/test

OK, let's compare...

Your certbot command had:

and your "working test file" has:

Do you see the problem?

1 Like

Ok I finally found it thanks to your answer, /usr/share/nginx/html/.well-known/acme-challenge/ is a path in the docker container so /data/letsencrypt was actually correct since it is being mounted to the location in the docker container because of the -v /docker/letsencrypt-docker-nginx/src/letsencrypt/letsencrypt-site:/data/letsencrypt flag in my command.
What was going wrong however was the path in this command since I’ve placed the project in my home folder.

Thank you! :slight_smile:

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.