Skip to content

Instantly share code, notes, and snippets.

@4ley
Created March 28, 2017 12:10
Show Gist options
  • Save 4ley/8de19a5c1c01a43edd3f3a4143bafcac to your computer and use it in GitHub Desktop.
Save 4ley/8de19a5c1c01a43edd3f3a4143bafcac to your computer and use it in GitHub Desktop.
WordPress / Apache / Reverse Proxy
<VirtualHost ...>
...
# Reverse Proxy
ProxyRequests Off
#ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto "https"
ProxyPass /blog http://blog.example.org/blog
ProxyPassReverse /blog http://blog.example.org/blog
...
</VirtualHost>
/**
* Reverse Proxy
*/
define('WP_HOME', 'https://www.example.org/blog');
define('WP_SITEURL', 'https://www.example.org/blog');
if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$_SERVER['HTTPS'] = 'on';
$_SERVER['REQUEST_SCHEME'] = 'https';
}
if ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR']) ) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
if ( ! empty( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ) {
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment