Quick Summary: Blocking the
/.well-known/acme-challenge/path with a Cloudflare geo-blocking WAF rule will cause automated Let’s Encrypt SSL renewals to fail, leading to expired certificates and site downtime. To safely restrict traffic by country, you must explicitly exclude the ACME challenge directory from your firewall expression.
Introduction
Geo-blocking is a straightforward way to lock down regional staging sites, internal tools, or country-specific promotions like blog.newman.net.nz. Using Cloudflare’s Web Application Firewall (WAF) on the free tier, you can drop all traffic originating outside of New Zealand with a single custom rule.
However, blanket geo-blocking introduces a silent failure point: automated SSL/TLS certificate renewals. Certificate Authorities like Let’s Encrypt validate domain ownership over HTTP from servers scattered across the globe—mostly in the US and Europe. If your WAF blocks non-NZ traffic across the entire subdomain, those validation requests get dropped at the edge, your certificate renewal fails silently in the background, and your site eventually throws browser security warnings.
Prerequisites
Before configuring your Cloudflare security rules, ensure you have:
- A domain active on Cloudflare (Free tier or higher)
- The target subdomain’s DNS record set to Proxied (orange cloud) in the Cloudflare DNS dashboard
- An origin server configured with an ACME client (such as Certbot or
acme.sh) using HTTP-01 validation
Why is blocking /.well-known/acme-challenge/ a bad idea?
When an ACME client attempts to renew an SSL certificate via the standard HTTP-01 challenge, Let’s Encrypt places a temporary validation token on your server and requests it via [http://your-domain.com/.well-known/acme-challenge/](http://your-domain.com/.well-known/acme-challenge/)<token>.
Because Let’s Encrypt intentionally performs multi-perspective validation from multiple global data centers to prevent BGP hijacking, those requests will almost certainly originate outside your target country. If a Cloudflare WAF rule blocks that path:
- Renewals fail silently: Your cron job or systemd timer will fail every time it runs.
- Debugging is misleading: Everything looks fine when you test the site locally from inside New Zealand, masking the issue until the 90-day certificate finally expires.
- Outages happen suddenly: Once the certificate expires, browsers will hard-block visitors from accessing the subdomain until you manually disable the firewall rule and force a renewal.
How do you exclude ACME challenges from a Cloudflare geo-block rule?
To restrict traffic to New Zealand while keeping automated SSL renewals intact, combine a country-code check with a starts_with path exclusion in your Cloudflare WAF expression:
(http.host eq "blog.newman.net.nz" and not ip.geoip.country in {"NZ"} and not starts_with(http.request.uri.path, "/.well-known/acme-challenge/"))
Explanation of the Expression
http.host eq "blog.newman.net.nz": Scopes the rule strictly to the target subdomain so the rest of your root domain remains unaffected.not ip.geoip.country in {"NZ"}: Matches any incoming request originating from an IP address outside of New Zealand.not starts_with(http.request.uri.path, "/.well-known/acme-challenge/"): Carves out an exception for the ACME validation directory, allowing global Certificate Authority servers to verify the token without hitting the block action.
Comparison of Cloudflare Geo-Blocking Approaches
| WAF Rule Approach | SSL Renewal Impact | Security & SEO Trade-offs |
|---|---|---|
| Strict Geo-Block (No Exclusions) | Breaks HTTP-01 renewals | Maximum lockdown, but causes certificate expiration outages every 90 days. |
| Geo-Block + ACME Exclusion | Safe (Renewals pass) | Ideal for locked-down promotions or regional apps using standard Let’s Encrypt HTTP validation. |
| Geo-Block + ACME + Verified Bots | Safe (Renewals pass) | Adds and not cf.client.bot so search engine crawlers (like Googlebot) can still index the page from US servers. |
Step-by-Step Configuration Guide
- Navigate to Custom Rules: Log in to your Cloudflare dashboard, select your domain (
newman.net.nz), and go to Security > WAF > Custom rules. - Create a New Rule: Click Create rule and give it a clear name, such as
Geo-Lock Promotions to NZ. - Open the Expression Editor: Click Edit expression next to the visual rule builder so you can paste the raw filter syntax directly.
- Paste the WAF Expression: Enter the rule with the ACME challenge exclusion:
(http.host eq "blog.newman.net.nz" and not ip.geoip.country in {"NZ"} and not starts_with(http.request.uri.path, "/.well-known/acme-challenge/"))
- Set the Action and Deploy: Under Choose action, select Block (or Managed Challenge if you want to give legitimate overseas users a Turnstile prompt), then click Deploy.
Frequently Asked Questions (FAQ)
Is it safe to leave /.well-known/acme-challenge/ open to the world?
Yes. Your web server only serves static, random cryptographic tokens from that directory during the brief window a certificate is actively renewing. Outside of renewal windows, requests to that path simply return a standard 404 Not Found from your origin server, exposing no sensitive application logic.
What if I also want Google to index the geo-locked subdomain?
Search engine crawlers primarily operate out of US data centers and will be blocked by a strict NZ-only rule. To allow legitimate search crawlers through, append and not cf.client.bot inside the closing parenthesis of your WAF expression.
Can I avoid this issue entirely by using DNS-01 validation?
Yes. If you configure your ACME client (like Certbot with the certbot-dns-cloudflare plugin) to validate domain ownership via Cloudflare DNS TXT records instead of HTTP requests, Let’s Encrypt never needs to touch your web server over HTTP, allowing you to block all non-NZ HTTP paths without exception.
Conclusion
Locking down a subdomain by country in Cloudflare takes less than a minute, but forgetting how Certificate Authorities verify domain ownership is a classic trap that leads to expired SSL certificates. Adding a simple starts_with exclusion for /.well-known/acme-challenge/ keeps your regional borders tight while ensuring your HTTPS certificates renew automatically without manual intervention.
![]()