Cloudflare HTTP Strict Transport Security (HSTS): A Guide for Website Owners
Learn what HTTP Strict Transport Security (HSTS) does in Cloudflare, what to check before enabling it, and how to verify or disable it.
Facts that can change should include a source and check date. Benchmark claims should state the plan, region, method, and test period.
HTTP Strict Transport Security (HSTS) is intended for websites that already work correctly over HTTPS and need compliant browsers to remain on that secure connection. In Cloudflare, enabling HSTS adds the Strict-Transport-Security response header to HTTPS responses. Browsers can then change HTTP links to HTTPS and prevent users from bypassing certain SSL certificate warnings.
What HSTS depends on#
HSTS does not replace a working HTTPS configuration. Cloudflare’s SSL/TLS documentation explains that certificates encrypt traffic between visitors and a website. Cloudflare may use an edge certificate for visitor-to-Cloudflare traffic and an origin certificate for Cloudflare-to-server traffic.
Cloudflare says HTTPS must be enabled before HSTS is turned on and must remain enabled afterward. For a Cloudflare-managed site, check that you will not:
- Change DNS from Proxied to DNS only.
- Pause Cloudflare.
- Move nameservers away from Cloudflare.
- Redirect HTTPS traffic to HTTP.
- Disable SSL or allow certificates to become invalid or use mismatched hostnames.
If HTTPS is removed while HSTS is active, Cloudflare warns that the site may be inaccessible until HTTPS is restored or the configured HSTS period ends.
Enable HSTS in Cloudflare#
Cloudflare documents these dashboard steps:
- Open Edge Certificates.
- Select Enable HSTS.
- Confirm that you understand the warning.
- Select Next.
- Configure the HSTS settings.
- Select Save.
Cloudflare also documents API-based configuration and options for applying HSTS to a specific subdomain.
Choose the settings carefully#
Cloudflare’s documented settings include:
- Max Age Header: Controls how long browsers remember the HSTS policy. The dashboard can disable the header or set a period from one to twelve months.
- Include subdomains: Extends the policy from a parent domain to its subdomains. Every affected subdomain must support HTTPS.
- Preload: Allows browsers to preload the HSTS policy. Cloudflare cautions that this can make a site without HTTPS inaccessible.
- No-Sniff Header: Adds
X-Content-Type-Options: nosniff, a separate security-related response header.
Treat Include subdomains and Preload as coverage decisions. Enabling either can increase the number of hostnames that must continue working over HTTPS.
Disable HSTS#
Cloudflare documents disabling HSTS by setting Max Age Header to 0 (Disable) and saving the change. If No-Sniff Header was enabled through the same settings, turn it off separately if needed.
Check the configured hostname#
Cloudflare states that HSTS settings apply per hostname. When using an external scanner to check the response header, test the exact hostname where HSTS is configured. Do not substitute an IP address or a different hostname.
For the vendor’s configuration details, see Cloudflare’s HTTP Strict Transport Security (HSTS) documentation and Cloudflare’s SSL/TLS documentation.
Sources
- Cloudflare: HTTP Strict Transport Security (HSTS) Checked 2026-11-06
- Cloudflare SSL/TLS documentation Checked 2026-11-06