From 785c64f2ae4db5358bd200c5de8117bc1f3ee2bf Mon Sep 17 00:00:00 2001 From: Tristan Bessoussa Date: Sun, 3 Feb 2019 00:11:55 +0100 Subject: [PATCH] Detect HTTPS if wordpress is behind a reverse proxy (#413) See https://codex.wordpress.org/Function_Reference/is_ssl#Notes --- config/application.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config/application.php b/config/application.php index 269b977947..bb06227d15 100644 --- a/config/application.php +++ b/config/application.php @@ -89,6 +89,14 @@ Config::define('SCRIPT_DEBUG', false); ini_set('display_errors', 0); +/** + * Allow WordPress to detect HTTPS when used behind a reverse proxy or a load balancer + * See https://codex.wordpress.org/Function_Reference/is_ssl#Notes + */ +if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { + $_SERVER['HTTPS'] = 'on'; +} + $env_config = __DIR__ . '/environments/' . WP_ENV . '.php'; if (file_exists($env_config)) {