The SSL connection is being terminated by Cloudflare, not your WordPress server, so WordPress can't detect that it is being served over an SSL connection, and keeps trying to redirect to https
, causing a redirect loop which leads to the error you see in the browser.
Cloudflare sets the X-Forwarded-Proto HTTP header on requests to your origin server to let the origin server know the protocol being used between the client and Cloudflare.
You need modify your wp-config.php
to configure your WordPress install to look for the X-Forwarded-Proto
HTTP header, as documented at wordpress.org:
If WordPress is hosted behind a reverse proxy that provides SSL, but is hosted itself without SSL, these options will initially send any requests into an infinite redirect loop. To avoid this, you may configure WordPress to recognize the HTTP_X_FORWARDED_PROTO header (assuming you have properly configured the reverse proxy to set that header).
define('FORCE_SSL_ADMIN', true);
// in some setups HTTP_X_FORWARDED_PROTO might contain
// a comma-separated list e.g. http,https
// so check for https existence
if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && strpos( $_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false ) {
$_SERVER['HTTPS'] = 'on';
}