Created
June 20, 2018 09:20
-
-
Save aleksandar-babic/0cdd3244f4bf6b13dbed68de96ba4ab1 to your computer and use it in GitHub Desktop.
Wordpress behind NGINX reverse 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
location /blog/ { | |
#auth_basic "Restricted"; | |
#auth_basic_user_file /etc/nginx/.htpasswd; | |
proxy_pass https://test-blog.bitstarz.com/; | |
proxy_set_header X-Forwarded-Host $host; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
} |
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
// Proxy fix | |
define( 'WP_SITEURL', '/blog' ); | |
define( 'WP_HOME', '/blog' ); | |
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') | |
$_SERVER['HTTPS'] = 'on'; | |
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { | |
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST']; | |
} | |
$_SERVER['REQUEST_URI'] = "/blog".$_SERVER['REQUEST_URI']; | |
Thank you! I've been banging my head against my desk for a while to fix this!
As I wasn't using a subdirectory, I only need this bit in my wp-config.php file:
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')
$_SERVER['HTTPS'] = 'on';
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}
Thank you! Life saver.
Thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you!