I'm having issues renewing my SSL certificate using Certbot with Nginx on Alpine Linux. I’m stuck with 404 errors on the .well-known/acme-challenge/ directory during the certificate renewal process.
Domain: crm.anl.club
Operating System: Alpine Linux (Docker container)
Nginx Version: nginx/1.25.3
Certbot Command: certbot renew
I’m getting 404 errors when trying to validate the domain with the Let's Encrypt CA:
The error I’m seeing:
The Certificate Authority failed to download the temporary challenge files created by
2024-10-23 09:04:09,069:DEBUG:certbot._internal.display.obj:Notifying user:
Certbot failed to authenticate some domains (authenticator: webroot). The Certificate Authority reported these problems:
Domain: crm.anl.club
Type: unauthorized
Detail: 149.100.158.86: Invalid response from http://crm.anl.club/.well-known/acme-challenge/3khZWnYfVOD30Uwr5ZSmfGp2K-ZxvMMLaAsMD5SsiR8: 404
Hint: The Certificate Authority failed to download the temporary challenge files created by Certbot. Ensure that the listed domains serve their content from the provided --webroot-path/-w and
that files created there can be downloaded from the internet.
2024-10-23 09:04:09,070:DEBUG:certbot._internal.error_handler:Encountered exception:
Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/certbot/_internal/auth_handler.py", line 108, in handle_authorizations
self._poll_authorizations(authzrs, max_retries, max_time_mins, best_effort)
File "/usr/lib/python3.11/site-packages/certbot/_internal/auth_handler.py", line 212, in _poll_authorizations
raise errors.AuthorizationError('Some challenges have failed.')
certbot.errors.AuthorizationError: Some challenges have failed.
2024-10-23 09:04:09,070:DEBUG:certbot._internal.error_handler:Calling registered functions
2024-10-23 09:04:09,070:INFO:certbot._internal.auth_handler:Cleaning up challenges
2024-10-23 09:04:09,070:DEBUG:certbot._internal.plugins.webroot:Removing /usr/share/nginx/html/.well-known/acme-challenge/3khZWnYfVOD30Uwr5ZSmfGp2K-ZxvMMLaAsMD5SsiR8
2024-10-23 09:04:09,071:DEBUG:certbot._internal.plugins.webroot:All challenges cleaned up
2024-10-23 09:04:09,071:ERROR:certbot._internal.renewal:Failed to renew certificate crm.anl.club with error: Some challenges have failed.
2024-10-23 09:04:09,073:DEBUG:certbot._internal.renewal:Traceback was:
Can you explain more about the "container"? What is running in the host and what is running in containers? Is Certbot running in the same container as nginx?
Also, do you still have that test.txt file in your acme-challenge folder? Because I cannot see it
curl -i http://crm.anl.club/.well-known/acme-challenge/test.txt
HTTP/1.1 404 Not Found
Server: nginx/1.25.3
The host is an ubuntu and the guest is a docker container running an alpine.
This is super weird, you are right, I can't download the file, but it's there.
/usr/share/nginx/html # ls -l .well-known/acme-challenge/test.txt
-rwxr-xr-x 1 nginx nginx 10 Oct 22 15:17 .well-known/acme-challenge/test.txt
If you can't see it then Let's Encrypt won't find it either I am not a container expert but you should just review your port and volume shares carefully.
I also don't see any "home" page for that domain. Is there any other URL that should work?
curl -i http://crm.anl.club
HTTP/1.1 404 Not Found
Server: nginx/1.25.3
Do you have an nginx server running in both the host and a container? The replying nginx does look like what you said is your Alpine but just want to make sure.
Any HTTP request on port 80 get "404" (even home page)
But, HTTPS requests on port 443 work properly (ignoring the expired cert).
There is probably something wrong with your nginx config. Sometimes this kind of thing happens if you route port 80 to the wrong place. But, the "Server" response header for both HTTP and HTTPS are identical so I don't think that is what is happening here.
Can you show entire output of the below command? An upper case T is essential. The info will be very long. If you cannot copy/paste the entire output then redirect to an output file and upload that.