Hướng dẫn giải pháp Solution guide Application Services Application Services ~10 phút ~10 min Đồng bộ 2026-06-10 Synced 2026-06-10

Enforce HTTPS và encrypt all traffic (Free, Pro, và Business) Enforce HTTPS and encrypt all traffic (Free, Pro, and Business)

Hướng dẫn chi tiết đồng bộ từ docs Cloudflare — mỗi section có backlink tới đúng vị trí trên trang gốc. Detailed guide synced from Cloudflare docs — each section links to the matching anchor on the official page.

← Danh mục ← Catalog

Giải thích nhanh Quick context

Thuộc nhóm Application Services — tập trung bảo vệ, tăng tốc và vận hành ứng dụng/web phía trước origin. Tutorial «Enforce HTTPS và encrypt all traffic (Free, Pro, và Business)» giúp bạn làm quen luồng triển khai thật — phù hợp đọc trước khi mở tài liệu gốc tiếng Anh. Đọc phần tóm tắt và lưu ý trước — sau đó mở docs gốc để copy lệnh và cấu hình chi tiết.

Configure SSL/TLS encryption from edge to origin, redirect HTTP to HTTPS, and harden your HTTPS setup with HSTS and minimum TLS versions.

Lưu ý trước khi làm Notes before you start

  • Đây là bản tóm tắt trên Orange Cloud Learning Hub — không thay thế tài liệu chính thức. This is a summary on Orange Cloud Learning Hub — it does not replace the official documentation.
  • Luôn mở liên kết «Tài liệu gốc» bên dưới khi cần lệnh CLI, snippet code và ảnh minh họa đầy đủ. Open the Official docs link below for CLI commands, code snippets, and full screenshots.
  • Docs Cloudflare cập nhật thường xuyên — đối chiếu ngày «Rà soát lần cuối» trên trang gốc khi triển khai production. Cloudflare docs change frequently — verify the Last reviewed date on the official page before production use.

Tổng quan Overview

Phần «Tổng quan» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Overview" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗

HTTPS on Cloudflare involves two separate connections: visitor to Cloudflare, and Cloudflare to your origin server. Both must be encrypted for end-to-end security. This guide walks through five stages:

  1. Configure your SSL/TLS encryption mode.
  2. Redirect all HTTP requests to HTTPS.
  3. Harden your HTTPS setup with minimum TLS versions and HSTS.
  4. Monitor third-party scripts on your pages.
  5. Verify your configuration.

The core workflow is available on Free, Pro, and Business plans.

Most procedures in this guide are configured per domain or zone. Select your domain in the Cloudflare dashboard before starting. Client-Side Security is the exception: it is configured at the account level.

Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs)

Cấu hình your SSL/TLS encryption mode Configure your SSL/TLS encryption mode

Phần «Cấu hình your SSL/TLS encryption mode» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Configure your SSL/TLS encryption mode" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗

Your SSL/TLS encryption mode controls how Cloudflare connects to your origin server. For end-to-end encryption, use Full (strict) — it encrypts both connections and verifies your origin certificate. For a detailed comparison of all available modes, refer to Encryption modes.

Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs)

Check your current mode Check your current mode

Phần «Check your current mode» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Check your current mode" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗
  1. In the Cloudflare dashboard, go to the SSL/TLS Overview page.

Go to Overview

  1. Check the current encryption mode displayed on the page.

If the mode is already Full (strict), skip to Redirect all HTTP requests to HTTPS. If the mode is not Full (strict), continue below to install an origin certificate (if needed) and change the mode.

Cài đặt Cloudflare Origin CA certificate Install a Cloudflare Origin CA certificate

Phần «Cài đặt Cloudflare Origin CA certificate» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Install a Cloudflare Origin CA certificate" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗

If your origin server does not have a valid SSL certificate, install a free Cloudflare Origin CA certificate. Origin CA certificates are valid for up to 15 years and are trusted by Cloudflare, which means you can set your encryption mode to Full (strict) after installing one.

If your origin already has a valid certificate from a publicly trusted certificate authority, skip to Set your encryption mode to Full (strict).

  1. Go to the Origin Server page.

Go to Origin Server

  1. On the Origin Certificates tab, select Create Certificate.
  2. Choose either:

Generate private key and CSR with Cloudflare: Private key type can be RSA or ECC. Use my private key and CSR: Paste your Certificate Signing Request (CSR) into the text field.

  1. List the hostnames (including wildcards) the certificate should protect with SSL encryption. The zone apex and first level wildcard hostname are included by default.
  2. Choose a Certificate Validity period.
  3. Select Create.
  4. Choose the Key Format:

Servers using OpenSSL (such as Apache and NGINX) generally expect PEM files (Base64-encoded ASCII), but also work with binary DER files. Servers using Windows and Apache Tomcat require PKCS#7 (a .p7b file).

  1. Copy the signed Origin Certificate and Private Key into separate files. For security reasons, you cannot see the Private Key after you exit this screen.
  2. Select OK.

For details about working with certificates programmatically, refer to API calls.

  1. Upload the Origin CA certificate to your origin web server.
  2. Update your web server configuration to use the certificate. For server-specific installation instructions, refer to Origin CA certificates.
  3. (Required for some servers) Upload the Cloudflare CA root certificate to your origin server.
  4. Enable SSL and port 443 at your origin web server.

If you do not see your server listed, search the DigiCert documentation ↗ or contact your hosting provider.

Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs)

Set your encryption mode to Full (strict) Set your encryption mode to Full (strict)

Phần «Set your encryption mode to Full (strict)» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Set your encryption mode to Full (strict)" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗

After installing a valid certificate on your origin server, set the encryption mode to Full (strict) by following the steps below.

To change your encryption mode in the dashboard:

  1. In the Cloudflare dashboard, go to the SSL/TLS Overview page.

Go to Overview

  1. Choose an encryption mode.

To adjust your encryption mode with the API, send a PATCH request with ssl as the setting name in the URI path, and the value parameter set to your desired setting (off, flexible, full, strict, or origin_pull).

Warning

If your site shows a 526 error after changing the encryption mode, your origin certificate may not meet the requirements for Full (strict). The certificate must be unexpired, issued by a trusted CA or Cloudflare Origin CA, and contain a Common Name (CN) or Subject Alternative Name (SAN) that matches your hostname. For redirect loop issues, refer to ERR\TOO\MANY\_REDIRECTS.

Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs)

Redirect all HTTP requests to HTTPS Redirect all HTTP requests to HTTPS

Phần «Redirect all HTTP requests to HTTPS» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Redirect all HTTP requests to HTTPS" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗

Even with an active edge certificate, visitors can still access resources over unsecured HTTP connections. Two settings work together to fix this:

  1. Always Use HTTPS redirects HTTP requests to HTTPS
  2. Automatic HTTPS Rewrites fixes mixed content references in your page HTML

Turn on Always Use HTTPS Turn on Always Use HTTPS

Phần «Turn on Always Use HTTPS» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Turn on Always Use HTTPS" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗

Always Use HTTPS redirects all HTTP requests to HTTPS before they reach your origin.

If only some parts of your application can support HTTPS traffic, do not turn on Always Use HTTPS. Use a single redirect to selectively redirect specific paths to HTTPS instead. Refer to Redirect admin area requests to HTTPS for an example.

  1. In the Cloudflare dashboard, go to the SSL/TLS Overview page.

Go to Overview

  1. Make sure that your SSL/TLS encryption mode is not set to Off. When the encryption mode is Off, the Always Use HTTPS option is not visible in the dashboard.
  2. Go to the Edge Certificates page.
  3. Turn on Always Use HTTPS.
  1. Make sure that your SSL/TLS encryption mode is not set to Off.
  2. Send a PATCH request with alwaysusehttps as the setting name in the URI path, and the value parameter set to "on".

Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs)

Turn on Automatic HTTPS Rewrites Turn on Automatic HTTPS Rewrites

Phần «Turn on Automatic HTTPS Rewrites» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Turn on Automatic HTTPS Rewrites" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗

Automatic HTTPS Rewrites prevents mixed content errors by rewriting HTTP resource URLs in your page HTML to HTTPS. This is useful for sites where you do not control all asset URLs, such as CMS-hosted content or embedded third-party resources.

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

Go to Edge Certificates

  1. For Automatic HTTPS Rewrites, switch the toggle to On.

Send a PATCH request with automatichttpsrewrites as the setting name in the URI path, and the value parameter set to "on".

Automatic HTTPS Rewrites does not rewrite all HTTP URLs. Some passive content (such as images) may not be rewritten, which can still cause mixed content warnings. For details on how rewrites work and troubleshooting, refer to Automatic HTTPS Rewrites and Mixed content errors.

Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs)

Harden your HTTPS configuration Harden your HTTPS configuration

Phần «Harden your HTTPS configuration» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Harden your HTTPS configuration" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗

After your encryption mode is set and HTTP traffic is redirected, strengthen your configuration by setting a minimum TLS version, turning on HTTP Strict Transport Security (HSTS), and turning on TLS 1.3.

Set your minimum TLS version Set your minimum TLS version

Phần «Set your minimum TLS version» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Set your minimum TLS version" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗

TLS 1.0 and 1.1 have known vulnerabilities and are no longer considered secure. Setting the minimum TLS version to 1.2 blocks connections from clients using older protocols. For guidance on which version to choose, refer to TLS protocols.

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

Go to Edge Certificates

  1. For Minimum TLS Version, select TLS 1.2.

Send a PATCH request with mintlsversion as the setting name in the URI path, and the value parameter set to "1.2".

Per-hostname minimum TLS version requires Advanced Certificate Manager

To set minimum TLS versions for individual hostnames instead of the entire zone, refer to Per-hostname setup. This requires an Advanced Certificate Manager subscription.

Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs)

Turn on TLS 1.3 Turn on TLS 1.3

Phần «Turn on TLS 1.3» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Turn on TLS 1.3" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗

TLS 1.3 provides faster handshakes and improved security over TLS 1.2.

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

Go to Edge Certificates

  1. For TLS 1.3, switch the toggle to On.

Send a PATCH request with tls13 as the setting name in the URI path, and the value parameter set to "on". To also turn on 0-RTT (Zero Round Trip Time Resumption), set the value to "zrt".

Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs)

Turn on HSTS Turn on HSTS

Phần «Turn on HSTS» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Turn on HSTS" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗

HTTP Strict Transport Security (HSTS) adds a response header that tells browsers to connect to your site over HTTPS only, even if a link or redirect tries to send them over HTTP. HSTS protects against protocol downgrade attacks.

Warning

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.
  1. In the Cloudflare dashboard, go to the Edge Certificates page.

Go to Edge Certificates

  1. For HTTP Strict Transport Security (HSTS), select Enable HSTS.
  2. Read the dialog and select I understand.
  3. Select Next.
  4. 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: nosniff header. Turn on to prevent browsers from MIME-type sniffing.

  1. 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.

Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs)

Review your cipher suites Review your cipher suites

Phần «Review your cipher suites» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Review your cipher suites" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗

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.

Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs)

Monitor third-party scripts với client-side security Monitor third-party scripts with client-side security

Phần «Monitor third-party scripts với client-side security» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Monitor third-party scripts with client-side security" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗

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 Turn on script monitoring

Phần «Turn on script monitoring» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Turn on script monitoring" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗
  1. In the Cloudflare dashboard, go to the Security Settings page.

Go to Settings

  1. (Optional) Filter by Client-side abuse.
  2. Turn on Continuous script monitoring.

Review detected resources Review detected resources

Phần «Review detected resources» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Review detected resources" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗

After turning on monitoring, it may take some time for Cloudflare to generate a list of detected scripts on your domain.

  1. In the Cloudflare dashboard, go to the Web assets page.

Go to Web assets

  1. Select the Client-side resources tab.
  2. 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.

Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs)

Xác minh your configuration Verify your configuration

Phần «Xác minh your configuration» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Verify your configuration" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗

After completing the previous stages, verify that your HTTPS configuration works as expected.

Sử dụng Automatic SSL/TLS Use Automatic SSL/TLS

Phần «Sử dụng Automatic SSL/TLS» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Use Automatic SSL/TLS" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗

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:

  1. In the Cloudflare dashboard, go to the SSL/TLS Overview page.

Go to Overview

  1. 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.

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.

Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs)

Test với external tools Test with external tools

Phần «Test với external tools» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Test with external tools" section below — open the official docs link for full screenshots and configuration tabs.

Mở section docs gốc ↗ Open source section ↗

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.

Terminal window

text
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:CONNECTCRSRVR_HELLO:tlsv1 alert

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.

Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs)

Xem bản đầy đủ trên developers.cloudflare.com (ảnh, tab cấu hình). View the full guide on developers.cloudflare.com (images, config tabs).

Tài liệu gốc ↗ Official docs ↗