Redirect loop detected

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.

4 Likes