Created
July 10, 2025 16:03
-
-
Save stefanpejcic/13ec249383698bb93309e18314ed7a9c to your computer and use it in GitHub Desktop.
WordPress Must-use plugin for HTTPS behind Varnish Proxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: HTTPS for wp-admin | |
* Description: Forces SSL for wp-admin via X-Forwarded-Proto. | |
* | |
* https://wpxss.com/wp-config-php/how-to-set-up-wordpress-behind-a-secure-reverse-proxy-using-nginx/ | |
*/ | |
add_action('muplugins_loaded', function () { | |
if ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) { | |
$_SERVER['HTTPS'] = 'on'; | |
} | |
if ( ! defined('FORCE_SSL_ADMIN') ) { | |
define('FORCE_SSL_ADMIN', true); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment