From aaed69252b399aa66bdcd5b3723f44cdb6ec4484 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 18 Dec 2018 20:41:06 +0100 Subject: Support of proxies with subfolder / path rules (#2191) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support HTTP_X_FORWARDED_PREFIX HTTP_X_FORWARDED_HOST Improve Docker/Træfik for rules based on path/sub-folder --- lib/Minz/Request.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/Minz/Request.php') diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index 24e30546f..8b2b610d6 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -118,7 +118,9 @@ class Minz_Request { $https = self::isHttps(); - if (!empty($_SERVER['HTTP_HOST'])) { + if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { + $host = parse_url('http://' . $_SERVER['HTTP_X_FORWARDED_HOST'], PHP_URL_HOST); + } elseif (!empty($_SERVER['HTTP_HOST'])) { //Might contain a port number, and mind IPv6 addresses $host = parse_url('http://' . $_SERVER['HTTP_HOST'], PHP_URL_HOST); } elseif (!empty($_SERVER['SERVER_NAME'])) { @@ -142,6 +144,9 @@ class Minz_Request { } else { $url .= '://' . $host . ($port == 80 ? '' : ':' . $port); } + if (!empty($_SERVER['HTTP_X_FORWARDED_PREFIX'])) { + $url .= rtrim($_SERVER['HTTP_X_FORWARDED_PREFIX'], '/ '); + } if (isset($_SERVER['REQUEST_URI'])) { $path = $_SERVER['REQUEST_URI']; $url .= substr($path, -1) === '/' ? substr($path, 0, -1) : dirname($path); -- cgit v1.2.3