From 8e4be773685f7dff074f23e2df13072577091f44 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 3 Jan 2017 14:17:05 +0100 Subject: Hide default port in local URL behind a reverse proxy --- application/HttpUtils.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'application') diff --git a/application/HttpUtils.php b/application/HttpUtils.php index e705cfd6..e8fc1f5d 100644 --- a/application/HttpUtils.php +++ b/application/HttpUtils.php @@ -297,9 +297,17 @@ function server_url($server) // Keep forwarded port if (strpos($server['HTTP_X_FORWARDED_PORT'], ',') !== false) { $ports = explode(',', $server['HTTP_X_FORWARDED_PORT']); - $port = ':' . trim($ports[0]); + $port = trim($ports[0]); } else { - $port = ':' . $server['HTTP_X_FORWARDED_PORT']; + $port = $server['HTTP_X_FORWARDED_PORT']; + } + + if (($scheme == 'http' && $port != '80') + || ($scheme == 'https' && $port != '443') + ) { + $port = ':' . $port; + } else { + $port = ''; } } -- cgit v1.2.3