diff --git a/system/typemill/Static/Urlinfo.php b/system/typemill/Static/Urlinfo.php index 2033c9e..bdb5445 100644 --- a/system/typemill/Static/Urlinfo.php +++ b/system/typemill/Static/Urlinfo.php @@ -35,8 +35,10 @@ class Urlinfo { $uri = self::updateHost($uri); - $uri = self::updateHost($uri); - + $uri = self::updateProto($uri); + + $uri = self::updatePort($uri); + $basepath = self::updateBasepath($basepath); } } @@ -110,7 +112,7 @@ class Urlinfo private static function updateBasepath($basepath) { -# $basepath = ""; + $basepath = ""; # if proxy has basepath, then if (isset($_SERVER['HTTP_X_FORWARDED_PREFIX'])) @@ -122,6 +124,23 @@ class Urlinfo return $basepath; } + protected static function updatePort($uri) + { + $port = $_SERVER['HTTP_X_FORWARDED_PORT'] ?? null; + + if ($port) + { + $port = trim(current(explode(',', $port))); + + if (preg_match('/^\d+\z/', $port)) + { + return $uri->withPort((int) $port); + } + } + + return $uri; + } + private static function checkIp($trustedProxies) { # optionally check trusted proxies diff --git a/system/typemill/settings/defaults.yaml b/system/typemill/settings/defaults.yaml index 9fcf333..fd871fb 100644 --- a/system/typemill/settings/defaults.yaml +++ b/system/typemill/settings/defaults.yaml @@ -1,4 +1,4 @@ -version: '2.5.0' +version: '2.6.0' title: 'Typemill' author: 'Unknown' copyright: false