Skip to content
FunnelGuard

Fix guide by FunnelsGuard

CDN SSL mode Flexible causing redirect loops: how to fix it

OPS-114High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

A CDN (content delivery network) sits between your visitors and your server. The SSL mode controls how that second leg, CDN to server, is encrypted. In Flexible mode the visitor's connection to the CDN is HTTPS, but the CDN's connection to your server is plain HTTP.

The loop starts when your server, CMS or a plugin sees an HTTP request and answers with a redirect to the HTTPS version. The CDN follows the same route again, over HTTP, and gets the same redirect. The browser gives up with a message like "This page isn't working: redirected you too many times".

How the loop happens
  1. VisitorOpens https://yoursite.com from an ad
  2. CDN (Flexible)Forwards the request to your server over HTTP
  3. Origin serverSees HTTP and redirects to HTTPS, again and again
  4. Landing pageNever loads
  5. Form or checkoutNever reached

The CDN keeps asking the server over HTTP, and the server keeps redirecting to HTTPS.

Why it costs you leads or sales

A redirect loop shows an error page instead of your site. Every visitor who hits an affected URL leaves, and paid clicks are wasted. Because the loop can be limited to some pages (for example only the checkout or a WordPress admin area, where a plugin forces HTTPS), the homepage may look fine while the pages that earn money are broken.

It often appears right after someone changes a setting: turning on a force-HTTPS plugin, moving to a new host, or switching the CDN on. You may not notice, because your own browser can have a cached good copy.

Form submissions per day around a SSL mode changeExample numbers
Form submissions per day around a SSL mode change (example)Before change: 24 submissions; Loop live, day 1: 0 submissions; Loop live, day 2: 0 submissions; After fix: 23 submissions0918240023Before changeLoop live, day 1Loop live, day 2After fixsubmissions

Example: illustrative numbers showing submissions dropping to zero while the loop is live and recovering after the fix.

How to check if your site has it

Signs of a Flexible SSL loop
  • The browser shows ERR_TOO_MANY_REDIRECTS or "redirected you too many times".
  • The site works when you pause or bypass the CDN, but fails when it is on.
  • In your CDN dashboard, SSL/TLS mode is set to Flexible.
  • Your server, host or a plugin forces HTTPS (a redirect rule, Really Simple SSL, an .htaccess rule, or a host setting).
  • It started after enabling the CDN, changing hosts or adding an HTTPS redirect.

Test from the command line to see the loop. The -L flag follows redirects, and --max-redirs stops it after a few hops.

Watch the redirect chainbash
curl -sIL --max-redirs 6 https://yoursite.com/ | grep -iE '^(HTTP|location)'

If you see the same location: https://yoursite.com/ line repeating, you have a loop. Also try a private window, since a cached redirect or cookie can hide or cause the problem in a normal one.

How to fix it

The proper fix is to make the CDN-to-server leg HTTPS as well. That means your server needs a valid certificate, then you set the CDN to Full (strict). Do not just remove the server's HTTPS redirect and stay on Flexible, as that leaves the CDN-to-server traffic unencrypted.

Fix the loop
  1. Install a valid certificate on your origin server

    Use your host's free certificate (often Let's Encrypt) or a CDN-issued origin certificate. Check that https://your-origin-address loads without errors.

  2. Change the CDN SSL mode

    In Cloudflare, go to SSL/TLS, then Overview, and choose Full (strict). Use Full only if your certificate is self-signed.

  3. Clear the CDN cache

    Purge cached redirects, then test in a private window.

  4. Check your site URL and redirect rules

    Make sure the site address uses https:// and that you have only one place forcing HTTPS (CMS, plugin, server or CDN rule), not several.

Platform-specific checks
  1. Set both URLs to HTTPS

    In Settings, then General, set WordPress Address and Site Address to https://. If locked out, set WP_HOME and WP_SITEURL in wp-config.php.

  2. Use one HTTPS redirect

    If a plugin such as Really Simple SSL is active, disable duplicate redirects in .htaccess or your host panel.

  3. Only if you must stay on Flexible

    Add the snippet shown below to wp-config.php so WordPress trusts the CDN's forwarded protocol. Moving to Full (strict) is still the better fix.

WordPress wp-config.php: trust the forwarded protocol (workaround)php
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
    $_SERVER['HTTPS'] = 'on';
}
Nginx: redirect only when the original request was HTTPnginx
if ($http_x_forwarded_proto = "http") {
    return 301 https://$host$request_uri;
}
SSL mode before and after

Flexible

  • Visitor to CDN: HTTPS
  • CDN to server: HTTP
  • Server forces HTTPS, so the request loops
  • Visitors see ERR_TOO_MANY_REDIRECTS

Full (strict)

  • Visitor to CDN: HTTPS
  • CDN to server: HTTPS with a valid certificate
  • Server sees HTTPS, no extra redirect
  • Pages, forms and checkout load

How to confirm it's fixed

Confirm the loop is gone
  1. Run the curl check again

    You should see one 301 at most, then a 200 response.

  2. Test in a private window and on mobile data

    This avoids cached redirects and local settings.

  3. Load key pages

    Open the homepage, a landing page, the form page and the checkout, with an ad-style URL that includes UTM parameters.

  4. Submit a test form

    Confirm the submission completes and the lead arrives.

How to prevent it happening again

Prevention
  • Keep the CDN on Full (strict) and note it in your setup docs.
  • Set a reminder to renew the origin certificate, or use auto-renewal.
  • Force HTTPS in only one place.
  • After any host move, CDN change or plugin install, load your key pages and submit a test form.
  • Test the live site on a schedule, not only after changes.

How FunnelGuard handles this

FunnelGuard detects this today. A robot visitor opens your pages on a schedule and runs your real journeys, such as lead forms and checkouts. If the page ends in a redirect loop or fails to load, the step fails. The failure is re-checked from a second region, and then one alert goes out by email, Slack, Teams, WhatsApp, webhook or PagerDuty, with a screenshot and a likely cause.

FunnelGuard sees the symptom (the page not loading), so you still need to check the SSL mode in your CDN to confirm the cause. The Free plan covers 1 site and 2 journeys with daily checks and no card, and paid plans include a 3-day free trial.

Questions people ask

Why does Cloudflare Flexible SSL cause too many redirects?

In Flexible mode Cloudflare contacts your server over HTTP. If your server or a plugin redirects HTTP to HTTPS, Cloudflare receives that redirect, asks again over HTTP and gets the same answer. The browser stops after too many hops and shows ERR_TOO_MANY_REDIRECTS.

How do I fix ERR_TOO_MANY_REDIRECTS on Cloudflare?

Install a valid certificate on your origin server, then set SSL/TLS to Full (strict) in the Cloudflare dashboard. Purge the cache and test in a private window. Also make sure only one thing on your site forces HTTPS.

What is the difference between Flexible, Full and Full (strict) SSL?

Flexible encrypts only visitor to CDN and uses HTTP to your server. Full encrypts both legs but accepts any certificate, including self-signed. Full (strict) encrypts both legs and requires a valid, trusted certificate that matches your domain.

Is it safe to use Flexible SSL?

Flexible leaves the connection between the CDN and your server unencrypted, so data on that leg could be read in transit. It is better to use Full (strict) with a valid origin certificate, especially if you collect form data or payments.

Why does my WordPress site loop after I enabled Cloudflare?

Usually WordPress or an HTTPS plugin sees the CDN's HTTP request and redirects it to HTTPS. Set your site URLs to https and switch Cloudflare to Full (strict). As a temporary workaround you can make WordPress read the X-Forwarded-Proto header.

Why does the site work for me but not for visitors?

Your browser may hold a cached good version or a different cookie state. Test in a private window, from another network, and with curl. A scheduled test from outside your network also shows what real visitors get.

Can switching to Full (strict) break my site?

Yes, if the origin certificate is expired, self-signed or issued for another hostname. You may then see 526 errors. Check the certificate on your server before you change the mode.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.