aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2018-12-18 20:41:06 +0100
committerGravatar GitHub <noreply@github.com> 2018-12-18 20:41:06 +0100
commitaaed69252b399aa66bdcd5b3723f44cdb6ec4484 (patch)
treea524b1a3bdb5d0378b5d1aab01239b5795411c6d /lib
parent1a1ed64ad5490100d3d3e3043ca86cd0a5643ea7 (diff)
Support of proxies with subfolder / path rules (#2191)
Support HTTP_X_FORWARDED_PREFIX HTTP_X_FORWARDED_HOST Improve Docker/Træfik for rules based on path/sub-folder
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/Request.php7
1 files changed, 6 insertions, 1 deletions
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);