Cloudflare puts three separate edge-side toggles in front of you that all sound like they do the same thing — Always Use HTTPS, Automatic HTTPS Rewrites, and HSTS — and a choice between three certificate sources (Universal, Advanced Certificate Manager, Custom). They do not mean the same thing and they do not have the same blast radius if you get them wrong. HSTS in particular is a commitment a browser will honour for as long as you tell it to, even if you change your mind. This article maps each toggle to what it actually does, when to use which certificate option, and where the irreversible decisions live.
How to verify
Read the current state of all three edge toggles and check what cert is being served:
# Always Use HTTPS state
curl -X GET "https://api.cloudflare.com/client/v4/zones/<zone-id>/settings/always_use_https" \
-H "Authorization: Bearer <token>"
# Automatic HTTPS Rewrites state
curl -X GET "https://api.cloudflare.com/client/v4/zones/<zone-id>/settings/automatic_https_rewrites" \
-H "Authorization: Bearer <token>"
# Current HSTS setting (max-age, includeSubDomains, preload)
curl -X GET "https://api.cloudflare.com/client/v4/zones/<zone-id>/settings/security_header" \
-H "Authorization: Bearer <token>"
# What cert is on the edge for this hostname?
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
| openssl x509 -noout -subject -issuer -dates
# Is the site already in the HSTS preload list?
curl -s "https://hstspreload.org/api/v2/status?domain=example.com"
The header value the browser sees in production tells the truth: curl -sI https://example.com/ | grep -i strict-transport-security.
What’s happening
Three things at the edge, in order:
- Always Use HTTPS is a redirect. A request that comes in over HTTP gets a 301 to the HTTPS version. The redirect lives at the edge and runs for every request, so it works even for a fresh visitor who has never seen the site before.
- Automatic HTTPS Rewrites is an HTML response filter. When the origin serves a page that contains a
http://example.com/...link, the edge rewrites it tohttps://...before sending to the browser. It catches stale links in your own content; it does NOT redirect the visitor. - HSTS is a response header (
Strict-Transport-Security). It tells the browser “for the next N seconds, refuse to load this hostname over HTTP, even if a link or address bar says http://”. Once a browser sees the header, it remembers it for themax-ageduration — even after the header disappears, even if the cert later breaks. The user cannot click through the warning.
HSTS preload goes one step further: you submit your domain to a list compiled by Google and used by every major browser. The hostname is then HSTS-on by default in fresh browser installs, before any header is seen. Removal from the preload list is slow (months) and propagation takes years as users update browsers. This is the irreversible part. The header values that the preload list requires are max-age of at least 31536000 seconds (1 year), includeSubDomains, and preload.
For edge certificates, the three options:
- Universal SSL — Cloudflare’s free option, on by default, covers the apex and one level of wildcard. SAN-based shared cert. Fine for most sites; the cert hostname list will include other Cloudflare customers (acceptable for almost everyone, sometimes a concern for compliance).
- Advanced Certificate Manager (ACM) — paid add-on. Dedicated cert per hostname or hostname pattern, choice of CA (Let’s Encrypt, Google Trust Services), longer validity options, custom CSR support. Worth the cost when the SAN-sharing of Universal SSL is a problem or when you need multi-level wildcards (e.g.
*.staging.example.com). - Custom Certificate — upload your own cert and key, signed by any CA you choose. The only option when an external auditor or partner requires a specific CA or extended-validation cert at the edge.
The procedure
-
Confirm the origin actually serves HTTPS first. Same precondition as the SSL/TLS mode work — see Flexible vs Full vs Full (Strict). Turning on Always Use HTTPS while the zone is on Flexible produces an infinite redirect loop.
-
Enable Always Use HTTPS. Dashboard: SSL/TLS → Edge Certificates → Always Use HTTPS. API:
curl -X PATCH "https://api.cloudflare.com/client/v4/zones/<zone-id>/settings/always_use_https" \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ --data '{"value":"on"}'From this point, any HTTP request gets a 301 to HTTPS.
-
Enable Automatic HTTPS Rewrites. Same panel. This is a safety net for in-page links — it doesn’t replace fixing the source. Search the origin database for hardcoded
http://example.com/and fix what you find. -
Configure HSTS — but conservatively first. Dashboard: SSL/TLS → Edge Certificates → HTTP Strict Transport Security (HSTS) → Enable HSTS. Start with
max-ageof 300 seconds (5 minutes),includeSubDomainsOFF,preloadOFF. Watch for a day. If a subdomain breaks because it’s HTTP-only, you’ve found it before committing to a year. -
Ramp up HSTS over a week. After 24 hours clean, raise
max-ageto 86400 (1 day). After a few days clean, to 604800 (1 week). After two weeks clean and once you’ve verified every subdomain serves HTTPS, raise to 31536000 (1 year) and enableincludeSubDomains. Verify the header from outside:curl -sI https://example.com/ | grep -i strict-transport-security # expect: strict-transport-security: max-age=31536000; includeSubDomains -
Submit to the HSTS preload list — only if you’re sure. Add
preloadto the header, re-verify with the curl above, then submit athttps://hstspreload.org/. Read the consequences page first. Once preloaded, every subdomain of the apex (includingstaging.example.com,intranet.example.com, anything you spin up later) is HTTPS-only in every modern browser by default. Removal takes months and never fully propagates. -
Pick the edge certificate source. Universal SSL is on by default and is the right answer for almost every site. Move to ACM when SAN-sharing matters, when you need wildcards beyond one level, or when you want to choose the CA. Move to Custom Certificate only when an external requirement names a specific CA — be ready to handle renewal yourself, since auto-renewal does not apply.
Common pitfalls
- Enabling HSTS with
includeSubDomainsbefore verifying every subdomain serves HTTPS — an HTTP-onlylegacy.example.combecomes unreachable for one year, and there is no way to bypass. - Submitting to the preload list during a migration, then needing to roll back to HTTP for an internal subdomain — preload removal takes months, and old browser installs keep the entry forever.
- Confusing Automatic HTTPS Rewrites with Always Use HTTPS — rewrites only touch HTML response bodies; they don’t redirect the visitor and they don’t help if a third-party link still points to
http://. - Buying ACM for the wrong reason — if Universal SSL already covers your hostnames and SAN-sharing is acceptable, ACM doesn’t add security, only operational features.
- Forgetting that Custom Certificate auto-renewal is your job. Universal SSL and ACM renew themselves; an uploaded Custom Certificate expires when its CA-issued cert expires.
In the engagements we run, the order is always the same: Always Use HTTPS first, Rewrites alongside, HSTS ramped over a week, preload submission only after a deliberate sign-off — and the edge cert choice driven by hostname needs, not by a default. Stack Harbor owns the HSTS clock and edge cert renewals under managed operations so a one-year header doesn’t outlive a careless toggle.