Skip to content

Instantly share code, notes, and snippets.

@gansbrest
Last active August 29, 2015 14:23
Show Gist options
  • Save gansbrest/7b8c5138bfcb48d4192e to your computer and use it in GitHub Desktop.
Save gansbrest/7b8c5138bfcb48d4192e to your computer and use it in GitHub Desktop.
http_host_proxy.patch
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 80b6eb1..5b28e98 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -333,7 +333,15 @@ function conf_path($require_settings = TRUE, $reset = FALSE) {
$confdir = 'sites';
$uri = explode('/', $_SERVER['SCRIPT_NAME'] ? $_SERVER['SCRIPT_NAME'] : $_SERVER['SCRIPT_FILENAME']);
- $server = explode('.', implode('.', array_reverse(explode(':', rtrim($_SERVER['HTTP_HOST'], '.')))));
+
+ // Special reverse proxy patch to allow prserve original HTTP_HOST header
+ // but load correct settings.php file
+ $settingsHeader = $_SERVER['HTTP_HOST'];
+ if (isset($_SERVER['HTTP_HOST_PROXY'])) {
+ $settingsHeader = $_SERVER['HTTP_HOST_PROXY'];
+ }
+
+ $server = explode('.', implode('.', array_reverse(explode(':', rtrim($settingsHeader, '.')))));
for ($i = count($uri) - 1; $i > 0; $i--) {
for ($j = count($server); $j > 0; $j--) {
$dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment