Last active
February 7, 2022 14:46
-
-
Save pietrorea/52465cbf207021cfd7928dbe693cee6c to your computer and use it in GitHub Desktop.
Wordpress wp-config.php - running behind a reverse proxy that terminates SSL
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
define( 'WP_HOME', 'https://yoursite.com/blog'); | |
define( 'WP_SITEURL', 'https://yoursite.com/blog'); | |
/** | |
* This is needed for a reverse proxy setup that terminates SSL and forwards /blog to another host. | |
* Without it, the Wordpress host doesn't know that it needs to make requests to itself using https. | |
*/ | |
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { | |
$_SERVER['HTTPS'] = 'on'; | |
} | |
/* Fixes al wp-admin/login links when running in a reverse proxy */ | |
$_SERVER['REQUEST_URI'] = str_replace("/wp-admin/", "/blog/wp-admin/", $_SERVER['REQUEST_URI']); | |
$_SERVER['REQUEST_URI'] = str_replace("/wp-login.php", "/blog/wp-login.php", $_SERVER['REQUEST_URI']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First set up with these scripts (Ubuntu 20.04 + LEMP):