diff --git a/src/install/install.php b/src/install/install.php index f32327b66..527dcfb3d 100644 --- a/src/install/install.php +++ b/src/install/install.php @@ -59,7 +59,15 @@ include PATH_LIBRARY . DIRECTORY_SEPARATOR . 'FOSSBilling' . DIRECTORY_SEPARATOR $loader = new FOSSBilling\AutoLoader(); $loader->register(); $protocol = FOSSBilling\Tools::isHTTPS() ? 'https' : 'http'; -$url = $protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + +// Detect if FOSSBilling is behind a proxy server +if(!empty($_SERVER['HTTP_X_FORWARDED_HOST'])){ + $host = $_SERVER['HTTP_X_FORWARDED_HOST']; +}else{ + $host = $_SERVER['HTTP_HOST']; +} + +$url = $protocol . '://' . $host . $_SERVER['REQUEST_URI']; $current_url = pathinfo($url, PATHINFO_DIRNAME); $root_url = str_replace('/install', '', $current_url) . '/'; define('SYSTEM_URL', $root_url); diff --git a/src/load.php b/src/load.php index 6eea147f5..1c0709921 100644 --- a/src/load.php +++ b/src/load.php @@ -33,7 +33,7 @@ function checkConfig() if (!$filesystem->exists(PATH_CONFIG)) { if ($filesystem->exists('install/index.php')) { // Build the base URL for the installation, including the protocol and hostname. - $base_url = 'http' . ((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on' || $_SERVER['HTTPS'] == 1)) || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') ? 's' : '') . '://' . ($_SERVER['HTTP_HOST'] ?? ''); + $base_url = 'http' . ((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on' || $_SERVER['HTTPS'] == 1)) || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') ? 's' : '') . '://' . (!empty($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']); // Append the directory name to the base URL. $base_url .= rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');