INTEGRITY Cloudflare Docs

HTTP Strict Transport Security (HSTS)

HSTS protects HTTPS web servers from downgrade attacks. These attacks redirect web browsers from an HTTPS web server to an attacker-controlled server, allowing bad actors to compromise user data and cookies.

HSTS adds an HTTP header that directs compliant web browsers to:

Before enabling HSTS, review the requirements.

Availability

Free Pro Business Enterprise
Availability Yes Yes Yes Yes

Requirements

In order for HSTS to work as expected, you need to:

Once you enabled HSTS, avoid the following actions to ensure visitors can still access your site:

Enable HSTS

To enable HSTS using the dashboard:

  1. In the Cloudflare dashboard, go to the Edge Certificates page.

    Go to Edge Certificates ↗
  2. For HTTP Strict Transport Security (HSTS), select Enable HSTS.

  3. Read the dialog and select I understand.

  4. Select Next.

  5. Configure the HSTS settings.

  6. Select Save.

To enable HSTS with the API, send a PATCH request with security_header as the setting name in the URI path, and specify the value object that includes your HSTS settings.

Disable HSTS

To disable HSTS on your website:

  1. In the Cloudflare dashboard, go to the Edge Certificates page.

    Go to Edge Certificates ↗
  2. For HTTP Strict Transport Security (HSTS), select Enable HSTS.

  3. Set the Max Age Header to 0 (Disable).

  4. If you previously enabled the No-Sniff header and want to remove it, set it to Off.

  5. Select Save.

Configuration settings

NameRequiredDescriptionOptions
Enable HSTS (Strict-Transport-Security)Yes

Serves HSTS headers to browsers for all HTTPS requests. HTTP (non-secure) requests will not contain the header.

Off / On
Max Age Header (max-age)Yes

Specifies duration for a browser HSTS policy and requires HTTPS on your website.

Disable, or a range from 1 to 12 months
Apply HSTS policy to subdomains (includeSubDomains)No

Applies the HSTS policy from a parent domain to subdomains. Subdomains are inaccessible if they do not support HTTPS.

Off / On
PreloadNo

Permits browsers to automatically preload HSTS configuration. Prevents an attacker from downgrading a first request from HTTPS to HTTP. Preload can make a website without HTTPS completely inaccessible.

Off / On
No-Sniff HeaderNo

Sends the X-Content-Type-Options: nosniff header to prevent Internet Explorer and Chrome from automatically detecting a content type other than those explicitly specified by the Content-Type header.

Off / On