All ArticlesDNS2026-11-08T13:45:06+08:00

Let's Encrypt Renewal Gets 403? Check WAF Rules on /.well-known/acme-challenge

HTTP-01 renewals start failing with a 403 or timeout after you add WAF rules, bot blocking, rate limiting, or .htaccess deny rules. After reading, you will be able to trace which security layer blocks the validation request and add a narrow exception for the challenge path without weakening protection for the rest of the site.

Your site loads fine in the browser, the certificate has a few weeks left, and then the renewal job starts failing with a 403 or a timeout. Nothing about the certificate itself changed. What usually changed is the security stack in front of the site: a new WAF rule set, bot blocking, rate limiting, a country block, or an .htaccess rule that denies hidden paths. This article walks through that pattern as a post-mortem, from first symptom to a fix that keeps the challenge path open without loosening protection elsewhere.

Impact: renewals fail while the site looks healthy

The confusing part of this failure is that nothing looks broken to humans. Visitors get pages, monitoring checks the homepage and gets a 200, and the only signal is a failed cron or systemd timer that nobody reads until the certificate is close to expiry. On the support desk it often shows up as a ticket saying the SSL certificate expired "by itself", with a renewal log full of the same error repeated daily.

The log usually says one of two things. Either the CA got an unexpected HTTP status (commonly 403, sometimes 429 or 503) when it fetched the challenge file, or it could not connect at all and timed out. Those two outcomes point to different layers, which is the first useful clue.

This is getting less forgiving over time. According to the CA/Browser Forum schedule, maximum certificate lifetimes drop to 100 days from March 15, 2027 and to 47 days from March 15, 2029. Shorter lifetimes mean more frequent renewals and less slack between a silent failure and an expired certificate. If you are still watching expiry dates by hand, this piece on manual tracking covers why that stops scaling.

Investigation: walk the request path layer by layer

With HTTP-01 validation, your ACME client (Certbot, acme.sh, AutoSSL, and so on) writes a small token file under /.well-known/acme-challenge/ in the webroot. The CA then requests http://yourdomain/.well-known/acme-challenge/<token> over port 80 and expects the exact token content back. Any layer between the internet and that file can interfere.

The fastest way to find the guilty layer is to reproduce the request from outside your network and then check whether it ever reached the web server. Place a plain text test file in the challenge directory of the webroot your ACME client uses, then run something like this from a machine that is not on the server or office network:

# From an external machine: request a test file in the challenge path
curl -i 'http://example.com/.well-known/acme-challenge/test-123'

# On the server: did the request reach the web server at all?
# Log path depends on distro and control panel
grep 'acme-challenge' /var/log/nginx/access.log | tail -n 20

Remove the test file when you are done. Then read the result against the layers below. The point is to match where the response came from, not just what status it had.

LayerTypical symptomWhere to look
Host firewall, fail2ban, or geo blockTimeout, nothing in the web server logFirewall rules and ban lists
CDN or cloud WAF in front of the origin403 or an HTML challenge page, no hit in the origin logThe WAF event log in the provider dashboard
ModSecurity on the origin403, with a matching entry and rule ID in the ModSecurity logModSecurity audit or error log
Rate limiting (for example nginx limit_req)429 or 503Web server error log, for nginx look for 'limiting requests'
.htaccess or server deny rules403 in the access log, no WAF entry.htaccess in the docroot and parent directories, server config

A common trap is that your own curl works while the CA still fails. That happens when your IP is allowlisted, when the block is geographic, or when a bot rule scores the request differently. Test from a location that is not trusted by any of your rules.

The discovery: the validator is not a normal visitor

Once the layer is found, the reason it fires is almost always the same. The validation request looks like the traffic security rules exist to stop.

It is an automated client with no cookies, no JavaScript, and no browser fingerprint, so JavaScript or CAPTCHA challenges fail by design. Even if a challenge page returns 200, the body is HTML instead of the token, and validation fails. The path starts with a dot segment, and many hardening snippets deny anything under a hidden path, such as the classic nginx location ~ /\. { deny all; } or a rewrite rule that rejects any URI containing /.. Let's Encrypt also validates from multiple network vantage points, so a country block or a firewall allowlist can pass one check and fail another. And it does not publish a fixed list of validation IPs, so allowlisting by address is not a dependable strategy.

Redirects are worth a separate note. An HTTP-to-HTTPS redirect is generally fine, because Let's Encrypt follows redirects to the HTTPS URL. But that means the HTTPS side, with its own WAF rules, now has to serve the token too. If the HTTP side passes and the HTTPS side has stricter rules, the failure appears to come from nowhere.

The User-Agent is not a safe key either. It can change, and anyone can send the same string.

Temporary mitigation: get the certificate renewed safely

If the certificate is close to expiry, the priority is one successful renewal. Avoid turning off the WAF for the whole site to get there. A short, path-scoped bypass is enough.

In practice that means adding an exception for the challenge path in whichever layer you identified, running the renewal once with your client's dry-run or staging option to confirm it passes, and then running the real renewal. Most clients have a dry-run mode, and using it avoids burning through the CA's production rate limits while you experiment.

If the blocking layer is a CDN or cloud WAF you cannot change quickly, switching that one certificate to DNS-01 validation is another way out, since it never touches port 80. That has its own credential trade-offs, covered in this comparison of full DNS API tokens and delegated challenge zones.

The lasting fix: a narrow, documented exception

The permanent version of the mitigation should be as small as possible: GET requests only, only the challenge directory, only filenames in the token character set (letters, digits, - and _). Everything else on the site keeps full protection.

For ModSecurity on the origin, a chained exclusion that loads before your core rule set does this. The rule ID here is a placeholder, so pick one that does not collide with existing rules:

# Load BEFORE the core rule set. Rule ID is a placeholder.
SecRule REQUEST_METHOD "@streq GET" "id:1000101,phase:1,pass,nolog,chain"
    SecRule REQUEST_URI "@rx ^/\.well-known/acme-challenge/[A-Za-z0-9_-]+$" "ctl:ruleEngine=Off"

This turns rule processing off only for requests that are GET and match the exact token pattern. A request like /.well-known/acme-challenge/../wp-login.php does not match the regex, so it still gets inspected.

For nginx, give the challenge path its own prefix location with ^~. That modifier stops regex locations, including a dot-file deny rule, from taking over:

location ^~ /.well-known/acme-challenge/ {
    root /var/www/example;   # must match the webroot your ACME client writes to
    default_type text/plain;
    allow all;
    try_files $uri =404;
}

Rate limiting needs one extra thought. In nginx, a limit_req set at server level is inherited by this location. A clean way around it is to build the limit_req_zone key through a map that returns an empty string for the challenge path, because requests with an empty key are not counted.

On Apache with .htaccess, put a condition such as RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/ before any rewrite rule that blocks hidden paths. If the deny comes from authorization directives instead, a small .htaccess inside the challenge directory with Require all granted (Apache 2.4 syntax) usually overrides it. That only works if AllowOverride permits it for that directory.

For a CDN or cloud WAF, the idea is the same, though the exact controls depend on the provider: a skip or exception rule matched on the URI path prefix, limited to GET, applied to bot and challenge features as well as managed rules. Check in the provider's event log that the exception actually matches. For host firewalls and fail2ban, make sure port 80 stays open and that jails watching web logs do not count requests to the challenge path.

Finally, write the exception down next to the rule itself. The next person who hardens the WAF or pastes a new security snippet needs to know why that path is open, or the same failure comes back with the next rule update.

The practical habit is simple: whenever you add or upgrade a security layer, run your ACME client's dry-run renewal right after, from the same server, and watch the result. A 403 or timeout there costs a few minutes to trace. Finding the same failure when the certificate has already expired costs a lot more, and with shorter lifetimes, that day arrives sooner.