Please fill out the fields below so we can help you better. Note: you must provide your domain name to get help. Domain names for issued certificates are all made public in Certificate Transparency logs (e.g. https://crt.sh/?q=example.com), so withholding your domain name here does not increase secrecy, but only makes it harder for us to provide help.
My domain is: https://band.snu.ac.kr
I ran this command: certbot certonly --webroot -w /opt/mrsnu.github.io/ -d band.snu.ac.kr -v
It produced this output:
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Certificate is due for renewal, auto-renewing...
Renewing an existing certificate for band.snu.ac.kr
Performing the following challenges:
http-01 challenge for band.snu.ac.kr
Using the webroot path /opt/mrsnu.github.io for all unmatched domains.
Waiting for verification...
Challenge failed for domain band.snu.ac.kr
http-01 challenge for band.snu.ac.kr
Certbot failed to authenticate some domains (authenticator: webroot). The Certificate Authority reported these problems:
Domain: band.snu.ac.kr
Type: connection
Detail: 147.46.15.17: Fetching http://band.snu.ac.kr/.well-known/acme-challenge/NJF3mw7CMde2oYCTus_ki57ux9sbXmjwQvmOjlUcJfE: Redirect loop detected
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.
Cleaning up challenges
Some challenges have failed.
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.
My web server is (include version): nginx/1.18.0 (Ubuntu)
The operating system my web server runs on is (include version): Ubuntu 20.04.6 LTS
My hosting provider, if applicable, is:
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 2.10.0
IssueFromLetsEncrypt
ERROR
A test authorization for band.snu.ac.kr to the Let's Encrypt staging service has revealed issues that may prevent any certificate for this domain being issued.
147.46.15.17: Fetching http://band.snu.ac.kr/.well-known/acme-challenge/ZWJC1MyXHAs24c5OKWx0ASSVxWR0GYvX9bwFzlxIPe8: Redirect loop detected
HTTPCheck
DEBUG
Requests made to the domain
Request to: band.snu.ac.kr/147.46.15.17, Result: [Address=147.46.15.17,Address Type=IPv4,Server=nginx/1.18.0 (Ubuntu),HTTP Status=302,Number of Redirects=2,Final HTTP Status=404], Issue:
Trace:
@0ms: Making a request to http://band.snu.ac.kr/.well-known/acme-challenge/letsdebug-test (using initial IP 147.46.15.17)
@0ms: Dialing 147.46.15.17
@661ms: Server response: HTTP 302 Found
@661ms: Received redirect to http://band.snu.ac.kr/00867224609/.well-known/acme-challenge/letsdebug-test
@661ms: Dialing 147.46.15.17
@1332ms: Server response: HTTP 302 Found
@1332ms: Received redirect to http://band.snu.ac.kr/.well-known/acme-challenge/letsdebug-test
@1332ms: Dialing 147.46.15.17
@2030ms: Server response: HTTP 404 Not Found
And here with curl
>curl -i http://band.snu.ac.kr/.well-known/acme-challenge/sometestfile
HTTP/1.0 302 Found
Location: http://band.snu.ac.kr/002770519539/.well-known/acme-challenge/sometestfile
Connection: close
Content-Type: text/html; charset=iso-8859-1
The above redirects http://band.snu.ac.kr/.well-known/acme-challenge/sometestfile
to http://band.snu.ac.kr/002770519539/.well-known/acme-challenge/sometestfile
>curl -i http://band.snu.ac.kr/002770519539/.well-known/acme-challenge/sometestfile
HTTP/1.0 302 Found
Location: http://band.snu.ac.kr/.well-known/acme-challenge/sometestfile
Connection: close
Content-Type: text/html; charset=iso-8859-1
The above redirects http://band.snu.ac.kr/002770519539/.well-known/acme-challenge/sometestfile
to http://band.snu.ac.kr/.well-known/acme-challenge/sometestfile
What firewalls or other network devices do you have between your nginx server and the public internet? Because it looks to me like some security device or software is doing an initial set of redirects. Possibly for any new IP address making a request.
See below series from my own test server
# Notice redirect with series of numbers after the domain name
curl -i http://band.snu.ac.kr/.well-known/acme-challenge/Test404
HTTP/1.0 302 Found
Location: http://band.snu.ac.kr/001246640706/.well-known/acme-challenge/Test404
Connection: close
Content-Type: text/html; charset=iso-8859-1
# Following that redirect gets redirected back to original
# This looks like a redirect loop except see next curl
curl -i http://band.snu.ac.kr/001246640706/.well-known/acme-challenge/Test404
HTTP/1.0 302 Found
Location: http://band.snu.ac.kr/.well-known/acme-challenge/Test404
Connection: close
Content-Type: text/html; charset=iso-8859-1
# Following that redirect (for the original URL) now does NOT get redirected
# Instead gets the expected 404 Not Found
# Also note the "Server: nginx" header which is not in above requests
curl -i http://band.snu.ac.kr/.well-known/acme-challenge/Test404
HTTP/1.1 404 Not Found
Server: nginx/1.18.0 (Ubuntu)
Date: Fri, 17 May 2024 13:39:34 GMT
Content-Type: text/html
Content-Length: 162
Connection: keep-alive
Something is probably associating the 12-digit number in your initial redirect with the IP address of the requester. Such that the subsequent requests from same IP don't get the extra redirects.
This is not a loop since it does finally resolve. But, it looks like one and Let's Encrypt protects itself by rejecting your cert request when it gets redirected back to the original URL.
Probably because whatever device or software is doing the redirect with the long number already recognized your IP address. See my previous post.
The Let's Encrypt servers often use different IP addresses. If I am right about this security device / software then you will often have cert request failures. If you repeat the cert request immediately after failure it might work if you get lucky and the LE servers still have their prior IP. This is not a good thing to rely on. You should find out what is doing the faulty redirect and correct that.
Or, consider using the DNS Challenge instead. That uses DNS records rather than HTTP requests to validate your domain.
I think you're right. Last time I wanted to renew the certificate, it kept not working then suddenly did after multiple attempts, even though I used the same command. And sometimes when I would try the same command but as a dry run (--dry-run), it would work...
Thanks for the tip! I'll check if there is any other device that does some redirects!
Yeah! I did try it at home (outside the local area), and it shows the same thing as your result.
I initially thought it was a firewall problem, since we originally blocked every incoming IP, but I checked with ufw and saw that we're currently allowing incoming access for port 80 and 443.