0

I finally managed to make my Wordpress page accessible via https / force https behind a reverse proxy thanks to this answer.

But now I can not get into the backend anymore. Any attempt to login just results in a redirect to the login page without actually logging in and the error message:

Error: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.

My attempts to solve this via changes to WP_HOME and WP_SITEURL just resulted in my prior problem being an endless redirect loop and my site not being reachable at all. My changes to the .htaccess file did not seem to have any effects at all, this might be because the proxy already enforces (redirects to) https.

Has anyone any idea why this is happening and how to solve it?

Thanks in advance!

My configuration from the linked answer:

wp-config:

define('WP_HOME','//'. $_SERVER['SERVER_NAME']);
define('WP_SITEURL','//'. $_SERVER['SERVER_NAME']);
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';

.htaccess:

 # http to https
 RewriteCond %{HTTP:X-Forwarded-Proto} =http
 RewriteRule . https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

Otherwise it is a clean wordpress page no plugins, default theme.

Jakob
  • 33
  • 6

1 Answers1

0

Because I suddenly got the cookie error message (don't know why I did not before my edit to the question) this was easy to solve on my own, thanks to this answer

My working configuration now is (varies from linked answer):

// Identify the relevant protocol for the current request

if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)$_SERVER['HTTPS']='on';

$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https" : "http";
 
// Set SITEURL and HOME using a dynamic protocol.
define('WP_SITEURL', $protocol . '://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', $protocol . '://' . $_SERVER['HTTP_HOST']);
Jakob
  • 33
  • 6