Skip to content

Commit 41552a1

Browse files
committed
fix: host resolution behind a load balancer
#31 Signed-off-by: Jack Cherng <jfcherng@gmail.com>
1 parent 6d81afc commit 41552a1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/Helper/RoundcubeHelper.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ public static function getSiteUrl(): string
1919
return $url;
2020
}
2121

22-
$scheme = filter_var($_SERVER['HTTPS'] ?? 'off', \FILTER_VALIDATE_BOOLEAN) ? 'https' : 'http';
23-
$requestedUrl = "{$scheme}://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
22+
$host = $_SERVER['HTTP_X_FORWARDED_HOST'] ?? $_SERVER['HTTP_HOST'];
23+
$scheme = $_SERVER['HTTP_X_FORWARDED_PROTO'] ?? (
24+
filter_var($_SERVER['HTTPS'] ?? 'off', \FILTER_VALIDATE_BOOLEAN) ? 'https' : 'http'
25+
);
26+
$requestedUrl = "{$scheme}://{$host}{$_SERVER['REQUEST_URI']}";
2427
$parts = parse_url($requestedUrl);
2528

2629
// remove potential trailing index.php

0 commit comments

Comments
 (0)