Skip to content

Mixed content warnings after moving a site behind Cloudflare

The padlock is there, but the console fills with Mixed Content errors and scripts or images stop loading. The origin is still generating http:// URLs — usually Flexible SSL or a scheme-detection gap. How to find the source and clean it up in the right order.

Mixed content after putting a site behind Cloudflare means the page arrives over HTTPS but still references http:// sub-resources. The browser, not Cloudflare, raises the warnings and does the blocking. The fix order matters: get the transport right (SSL mode), make the application detect the scheme correctly, then clean the stored http:// URLs out of the database and templates. Cloudflare’s Automatic HTTPS Rewrites is a safety net for stragglers, not the fix.

What’s happening

Mixed content is a browser policy about an HTTPS page requesting HTTP resources. Active content — scripts, stylesheets, XHR/fetch, iframes — is blocked outright. Passive content — images, audio, video — is auto-upgraded to HTTPS by current browsers and blocked if the upgrade fails. That is why a migration often looks like “the site works but looks broken”: stylesheets and scripts are being refused.

Behind Cloudflare the http:// URLs come from a few places. If the zone runs Flexible SSL, the origin receives plain HTTP and everything the application derives from the request scheme comes out as http:// — one more reason Flexible causes trouble, alongside the redirect loops covered in Flexible vs Full vs Full (Strict). Even on Full (Strict), an application behind a local proxy that ignores X-Forwarded-Proto can misdetect the scheme. And independent of all that, CMS databases accumulate hardcoded http:// URLs in posts, widgets, and theme options that survive any transport fix. Nothing here is plan-gated: Automatic HTTPS Rewrites is available on Free, Pro, and Business alike.

What to check first

  • The browser console on an affected page — it lists every blocked or upgraded URL, which is your work inventory.
  • The zone’s SSL mode under SSL/TLS → Overview.
  • Whether the flagged URLs are your own domain (fixable at the source) or third-party (only fixable by replacing the embed).
  • The CMS base URLs — for WordPress, the home and siteurl options.
  • The state of Automatic HTTPS Rewrites under SSL/TLS → Edge Certificates.

How to verify

# Inventory insecure references in the served HTML
curl -s https://example.com/ | grep -oE 'src="http://[^"]+"|href="http://[^"]+"' | sort | uniq -c | sort -rn | head -20

# WordPress: what does the CMS think its own URL is?
wp option get home
wp option get siteurl

# How much http:// is stored in the database? (dry run, counts only)
wp search-replace 'http://example.com' 'https://example.com' --all-tables --dry-run

If the curl inventory is clean but browsers still complain, you are probably looking at cached HTML — purge the Cloudflare cache and retest before chasing ghosts.

The fix

  1. Fix the transport first. If the zone is on Flexible, migrate to Full (Strict) with a certificate on the origin. Until the origin genuinely serves HTTPS, every downstream fix is fighting the architecture.
  2. Make the application see the right scheme. If anything in front of the app terminates TLS, the app must honour X-Forwarded-Proto. For WordPress, place this in wp-config.php above the wp-settings.php line:
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
    $_SERVER['HTTPS'] = 'on';
}
  1. Update the stored URLs. Set the CMS base URLs to https://, then run the database replacement for real once the dry run looks sane: wp search-replace handles serialized PHP data correctly, which raw SQL UPDATE statements do not — that distinction has destroyed widget configurations. The WordPress-specific sweep, including theme and page-builder storage, is covered in mixed content after SSL on WordPress.
  2. Turn on Automatic HTTPS Rewrites under SSL/TLS → Edge Certificates. It rewrites http:// references to https:// in HTML as it passes the edge — but only for hosts known to support HTTPS, so it will not catch everything. Treat it as insurance for the URLs you missed, not as the cleanup itself. Reference: developers.cloudflare.com/ssl/.
  3. Deal with third-party stragglers. An embed served by a host with no HTTPS support cannot be rewritten by anyone. Replace it, self-host the asset, or drop it.
  4. Optionally add a Content-Security-Policy: upgrade-insecure-requests header at the origin as a blunt final layer. It upgrades every sub-resource request; it also masks the underlying data problem, so use it after the cleanup, not instead of it.

When this fix is wrong

If the console error says the certificate of an HTTPS sub-resource is invalid, that is a certificate problem on the asset’s host, not mixed content — no rewrite will help. If a page is completely unstyled and redirects endlessly, you are in redirect-loop territory rather than mixed content. And warnings that appear only on one person’s machine are usually a browser extension injecting content, not your site.

Common mistakes

  • Installing a WordPress “SSL fixer” plugin that filters output on every request instead of correcting the stored data once — permanent overhead for a one-time cleanup.
  • Running a raw SQL search-and-replace across serialized fields and corrupting theme and widget settings.
  • Enabling Automatic HTTPS Rewrites, seeing fewer warnings, and declaring the job done while the database still says http://.
  • Forgetting non-HTML sources: srcset attributes, CSS url() references, and URLs emitted by JavaScript bundles all bypass a template-only sweep.

Prevention

Author content with relative URLs or scheme-correct absolute URLs, and make Full (Strict) the standing state so the origin never has a reason to generate http:// links. Add a check to your uptime or CI tooling that greps rendered pages for http:// references to your own domain — it is a one-line test that catches regressions the day a plugin or template reintroduces them.

Getting end-to-end TLS right — edge, origin certificate, and the redirect chain — is standard work inside Managed Cloud Ops; book an infrastructure review if you want it verified end to end.