Skip to content
Tutorials Center
My learning

Topics

Lesson 14 of 36 ยท Security: WAF and DDoS

Cloudflare SSL/TLS Modes: Flexible, Full, Full (Strict) and HSTS

Choose the right Cloudflare SSL/TLS encryption mode, install an Origin CA certificate, fix redirect loops, enable HSTS and Always Use HTTPS, and set a minimum TLS version.

When a proxy sits between browser and origin, there are two HTTPS connections to think about: visitor to Cloudflare, and Cloudflare to your server. The first is secured automatically. The second is controlled by the SSL/TLS encryption mode, one of the most important and most misunderstood settings in the dashboard (SSL/TLS > Overview).

flowchart LR
  B["Browser"] -- "Connection 1: edge certificate (managed by Cloudflare)" --> E["Cloudflare edge"]
  E -- "Connection 2: depends on the SSL/TLS mode" --> O["Origin server"]

The padlock in the browser only proves connection 1. The mode decides about connection 2.

The four modes

Mode Cloudflare to origin Certificate checked? Verdict
Off HTTP, and browsers get no HTTPS either n/a Never use
Flexible HTTP (unencrypted) n/a Avoid: traffic crosses the internet in clear
Full HTTPS No: self-signed or expired is accepted Acceptable only as a stopgap
Full (strict) HTTPS Yes: trusted CA or Cloudflare Origin CA, valid name, not expired Recommended

Flexible looks attractive because it needs nothing on the origin, but the second leg is plain HTTP, so anyone on the path (a hosting network, a compromised router) can read or change it. It also commonly causes redirect loops: the origin sees HTTP and redirects to HTTPS, Cloudflare again asks over HTTP, and the browser reports "too many redirects".

Full encrypts the second leg but does not verify who it is talking to, so an attacker who can intercept can present any certificate. Full (strict) verifies the certificate chain and the hostname, closing that hole.

Getting a certificate on the origin

You have two good options for Full (strict):

  1. A public CA certificate (for example from Let's Encrypt), renewed automatically by software like certbot or your hosting panel.
  2. A Cloudflare Origin CA certificate: in SSL/TLS > Origin Server create a certificate for example.com and *.example.com, with validity up to 15 years, and install the certificate and private key on the origin. It is trusted only by Cloudflare, so it works with Full (strict) as long as the hostname stays proxied (orange cloud). Grey-clouded names will show browser warnings.

Install on nginx as usual:

NGINX
server {
    listen 443 ssl;
    server_name example.com www.example.com;
    ssl_certificate     /etc/ssl/cloudflare/example.com.pem;
    ssl_certificate_key /etc/ssl/cloudflare/example.com.key;
}

The private key is shown only once in the dashboard and must be protected like a password.

JS Stand-in: will this mode work with my origin?

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The error numbers follow Cloudflare's own 5xx family: 525 means the TLS handshake with the origin failed, 526 means the certificate is invalid under Full (strict), and 521 means the origin refused the connection. The explanation lines are the practical lessons, and you will match them against real error pages when you debug.

Edge certificates

The certificate the browser sees is issued by Cloudflare. Universal SSL is free: it issues and renews certificates automatically for the apex and first-level wildcard (example.com and *.example.com). A hostname two levels deep, such as a.b.example.com, is not covered; use Advanced Certificate Manager (paid) or restructure the name. You can also upload custom certificates on higher plans.

Certificate validation happens through DNS or HTTP, so keep your CAA records (record types) compatible with Cloudflare's partner CAs.

Settings that harden HTTPS

Find these under SSL/TLS > Edge Certificates:

  • Always Use HTTPS redirects every http:// request to https:// at the edge.
  • HTTP Strict Transport Security (HSTS) tells browsers to use HTTPS only for a period (max-age), optionally for subdomains, and optionally to join the browser preload list. Start with a short max-age, check everything works over HTTPS, then raise it. Preloading is hard to undo, so enable it deliberately.
  • Minimum TLS Version. Prefer TLS 1.2 or higher; older versions are obsolete. Raise to 1.3 only if you know your visitors' clients support it.
  • TLS 1.3 should be on; it is faster and safer.
  • Automatic HTTPS Rewrites fixes http:// links in pages that cause mixed-content warnings.
  • Opportunistic Encryption and Onion Routing are minor extras.
  • Authenticated Origin Pulls make the edge present a client certificate so the origin accepts only Cloudflare (origin protection).
  • Automatic SSL/TLS can recommend or choose the strongest mode your origin supports; review its choice instead of trusting it blindly.

Fixing a redirect loop

  1. Check the SSL/TLS mode. If it is Flexible and the origin forces HTTPS, change to Full (strict) after installing a certificate.
  2. If you cannot change the mode, stop the origin from redirecting, or make it trust X-Forwarded-Proto / CF-Visitor.
  3. Look for several redirect layers: a CMS plugin, nginx, and a Cloudflare Redirect Rule can fight each other.
  4. Test with curl -sIL https://example.com | grep -i -E "^(HTTP|location)".
JS Stand-in: HSTS header builder

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which mode encrypts Cloudflare-to-origin traffic AND verifies the origin certificate?

    Only Full (strict) checks the chain, hostname and validity.
  2. 2. A site behind Flexible keeps showing 'too many redirects'. Likely cause?

    Switch to Full (strict) with a valid origin certificate.
  3. 3. Where is a Cloudflare Origin CA certificate trusted?

    It is meant for the edge-to-origin leg; browsers do not trust it.
  4. 4. What does HSTS do?

    Browsers remember the policy for max-age and refuse plain HTTP.
  5. 5. Does Universal SSL cover a.b.example.com?

    Two-level subdomains need Advanced Certificate Manager or a different name layout.

Summary

  • Two connections exist: browser to edge (automatic) and edge to origin (controlled by the mode).
  • Use Full (strict) with a public CA or Origin CA certificate; avoid Flexible and Off.
  • Universal SSL covers the apex and first-level wildcard.
  • Add Always Use HTTPS, HSTS (carefully), TLS 1.2+ and Authenticated Origin Pulls.

Next: WAF and managed rules