diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 549818756..a8212d135 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -65,12 +65,22 @@ class SettingsController extends Controller $start_settings['db_error'] = $e->getMessage(); } - $protocol = array_key_exists('HTTPS', $_SERVER) && ('on' == $_SERVER['HTTPS']) ? 'https://' : 'http://'; + if (array_key_exists("HTTP_X_FORWARDED_PROTO", $_SERVER)) { + $protocol = $_SERVER["HTTP_X_FORWARDED_PROTO"] . "://"; + } elseif (array_key_exists('HTTPS', $_SERVER) && ('on' == $_SERVER['HTTPS'])) { + $protocol = "https://"; + } else { + $protocol = "http://"; + } - $host = array_key_exists('SERVER_NAME', $_SERVER) ? $_SERVER['SERVER_NAME'] : null; - $port = array_key_exists('SERVER_PORT', $_SERVER) ? $_SERVER['SERVER_PORT'] : null; - if (('http://' === $protocol && '80' != $port) || ('https://' === $protocol && '443' != $port)) { - $host .= ':'.$port; + if (array_key_exists("HTTP_X_FORWARDED_HOST", $_SERVER)) { + $host = $_SERVER["HTTP_X_FORWARDED_HOST"]; + } else { + $host = array_key_exists('SERVER_NAME', $_SERVER) ? $_SERVER['SERVER_NAME'] : null; + $port = array_key_exists('SERVER_PORT', $_SERVER) ? $_SERVER['SERVER_PORT'] : null; + if (('http://' === $protocol && '80' != $port) || ('https://' === $protocol && '443' != $port)) { + $host .= ':'.$port; + } } $pageURL = $protocol.$host.$_SERVER['REQUEST_URI'];