mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Merge pull request #12611 from manuteleco/add_reverse_proxy_support_in_preflight
Fixed #10779: Add Reverse Proxy support to Pre-Flight URL check
This commit is contained in:
commit
39193a71b7
|
@ -65,12 +65,22 @@ class SettingsController extends Controller
|
||||||
$start_settings['db_error'] = $e->getMessage();
|
$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;
|
if (array_key_exists("HTTP_X_FORWARDED_HOST", $_SERVER)) {
|
||||||
$port = array_key_exists('SERVER_PORT', $_SERVER) ? $_SERVER['SERVER_PORT'] : null;
|
$host = $_SERVER["HTTP_X_FORWARDED_HOST"];
|
||||||
if (('http://' === $protocol && '80' != $port) || ('https://' === $protocol && '443' != $port)) {
|
} else {
|
||||||
$host .= ':'.$port;
|
$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'];
|
$pageURL = $protocol.$host.$_SERVER['REQUEST_URI'];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue