Enforce HTTPS and encrypt all traffic (F·续
Caution
Only turn on HSTS after your HTTPS configuration is fully working and tested. If you remove HTTPS before disabling HSTS or before waiting for the duration of the original Max Age Header, your website becomes inaccessible to visitors for the Max Age Header duration or until you re-enable HTTPS. Refer to HTTP Strict Transport Security (HSTS) before configuring.
Before turning on HSTS, confirm these prerequisites:
- HTTPS is enabled and working on your domain.
- Your DNS records are set to Proxied.
-
You are not redirecting HTTPS to HTTP anywhere.
-
In the Cloudflare dashboard, go to the Edge Certificates page. Go to Edge Certificates ↗
- For HTTP Strict Transport Security (HSTS), select Enable HSTS.
- Read the dialog and select I understand.
- Select Next.
- Configure the HSTS settings:
- Max Age Header: Choose a duration (start with 6 months, increase to 12 months after confirming stability).
- Apply HSTS policy to subdomains (includeSubDomains): Turn on if all your subdomains support HTTPS. Subdomains without HTTPS become inaccessible when this is enabled.
- Preload: Turn on only after setting Max Age Header to 12 months. Preload inclusion prevents downgrade attacks on the first visit. Submit your domain at hstspreload.org ↗︎ after turning on preload.
- No-Sniff Header: Sends the
X-Content-Type-Options: nosniffheader. Turn on to prevent browsers from MIME-type sniffing. - Select Save.
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.
Review your cipher suites
Cloudflare's default cipher suites provide strong encryption for most sites. You do not need to change them unless a security audit or compliance requirement specifies particular cipher configurations.
For details on the default cipher suites and how to customize them, refer to Cipher suites. For compliance-specific cipher configurations, refer to Customize cipher suites via API.
Custom cipher suites require Advanced Certificate Manager
Customizing cipher suites requires an Advanced Certificate Manager subscription. The default cipher suites are applied automatically on all plans.
Monitor third-party scripts with client-side security
HTTPS encrypts data in transit, but third-party scripts loaded by your pages can still exfiltrate data from the browser. Client-side security monitors these scripts and alerts you to unexpected additions.
Turn on script monitoring
- In the Cloudflare dashboard, go to the Security Settings page. Go to Settings ↗
- (Optional) Filter by Client-side abuse.
- Turn on Continuous script monitoring.
Review detected resources
After turning on monitoring, it may take some time for Cloudflare to generate a list of detected scripts on your domain.
- In the Cloudflare dashboard, go to the Web assets page. Go to Web assets ↗
- Select the Client-side resources tab.
- Review the list of detected scripts. Check for unknown or unexpected scripts from domains you do not recognize.
Depending on your Cloudflare plan, you may also be able to review connections made by scripts and check them for malicious activity. For setup details, refer to Get started with client-side security.
Content security rules require Client-Side Security Advanced
To block scripts not on your approved list, you can create content security rules that define an allowlist. This requires the Client-Side Security Advanced add-on. Refer to Content security rules for setup instructions.
Verify your configuration
After completing the previous stages, verify that your HTTPS configuration works as expected.
Use Automatic SSL/TLS
Cloudflare's Automatic SSL/TLS analyzes your origin server and selects the most secure encryption mode your origin supports. If your zone uses Automatic SSL/TLS (the default for new zones), Cloudflare adjusts the mode automatically and will not downgrade to a less secure mode if your origin certificate expires.
To check whether your zone uses Automatic SSL/TLS:
- In the Cloudflare dashboard, go to the SSL/TLS Overview page. Go to Overview ↗
- Check whether Automatic SSL/TLS or Custom SSL/TLS is selected. If Custom is selected and you want Cloudflare to manage the mode automatically, select Automatic SSL/TLS.
Note
The SSL/TLS Recommender is deprecated in favor of Automatic SSL/TLS. If you previously used the Recommender, Automatic SSL/TLS replaces it. Refer to SSL/TLS Recommender for migration details.
Test with external tools
Use SSL Labs Server Test ↗︎ to verify your HTTPS configuration from outside the Cloudflare network. Enter your domain and review the report. An A or A+ grade indicates that your TLS configuration, certificate chain, and protocol support meet current security standards.
To test supported TLS versions, attempt a request to your website or application while specifying a TLS version.
For example, to test TLS 1.1, use the curl command below. Replace www.example.com with your Cloudflare domain and hostname.
curl https://www.example.com -svo /dev/null --tls-max 1.1
If the TLS version you are testing is blocked by Cloudflare, the TLS handshake is not completed and returns an error:
* error:1400442E:SSL routines:CONNECT_CR_SRVR_HELLO:tlsv1 alert
Note
Local VPN or a device security client may prevent insecure connections using legacy protocols like TLS 1.0. Make sure to disable such network or security client before running the test on your device.
PCI DSS compliance
For PCI DSS compliance, TLS 1.2 is the minimum required version. Refer to PCI compliance and vulnerabilities mitigation for details.
Related resources
SSL/TLS
- Get started with SSL/TLS — onboarding guide for edge certificates, encryption modes, and HTTPS enforcement
- Encryption modes — detailed explanation of Off, Flexible, Full, and Full (strict) modes
- Cloudflare Origin CA — create free origin certificates trusted by Cloudflare
- Mixed content errors — troubleshoot HTTP resources loaded on HTTPS pages
- ERR_TOO_MANY_REDIRECTS — fix redirect loops caused by encryption mode misconfigurations
Client-side security
- Get started with client-side security — activate monitoring, review scripts, configure alerts, and create rules
- Client-side security and PCI DSS compliance — how client-side security maps to PCI DSS v4 requirements
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/use-cases/solutions/encrypt-all-keep-site-secure/#page","headline":"Enforce HTTPS and encrypt all traffic (Free, Pro, and Business)","description":"Configure SSL/TLS encryption from edge to origin, redirect HTTP to HTTPS, and harden your HTTPS setup with HSTS and minimum TLS versions.","url":"https://developers.cloudflare.com/use-cases/solutions/encrypt-all-keep-site-secure/","inLanguage":"en","image":"https://developers.cloudflare.com/use-cases/solutions/encrypt-all-keep-site-secure/og.png?v=46949290e9a93ea3","dateModified":"2026-08-25","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Block spam submissions, fake account creation, and card testing on your web forms using a layered defense. title: Protect your forms from spam and abuse (Free, Pro, and Business) image: https://developers.cloudflare.com/use-cases/solutions/protect-sensitive-forms-fraud-abuse/og.png?v=79d35783c9ccd7f5
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/use-cases/llms.txt
Use this file to discover all available pages before exploring further.
Docs