Skip to content

Instantly share code, notes, and snippets.

@aleksandar-babic
Created June 20, 2018 09:20
Show Gist options
  • Save aleksandar-babic/0cdd3244f4bf6b13dbed68de96ba4ab1 to your computer and use it in GitHub Desktop.
Save aleksandar-babic/0cdd3244f4bf6b13dbed68de96ba4ab1 to your computer and use it in GitHub Desktop.
Wordpress behind NGINX reverse proxy
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;
}
// 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'];
@itsfadnis
Copy link

Thank you! Life saver.

@LaserKaspar
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment