1
0
mirror of https://github.com/typemill/typemill.git synced 2025-08-01 11:50:28 +02:00

Improve Proxy detection in urlinfo

This commit is contained in:
trendschau
2024-06-14 22:40:41 +02:00
parent 77bc0a364c
commit 0d50ca2f6e
2 changed files with 23 additions and 4 deletions

View File

@@ -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

View File

@@ -1,4 +1,4 @@
version: '2.5.0'
version: '2.6.0'
title: 'Typemill'
author: 'Unknown'
copyright: false