mirror of https://github.com/MISP/MISP
Better automatic handling of the baseurl
- Used to simply take the server address - Switched to a method that tries to use SERVER_NAME > HTTP_HOST > SERVER_ADDRpull/1050/head
parent
5137bca58a
commit
1c3c68c4e0
|
@ -86,17 +86,20 @@ Cache::config('default', array('engine' => 'File'));
|
|||
Configure::load('config');
|
||||
|
||||
if (!Configure::read('MISP.baseurl')) {
|
||||
if (isset($_SERVER['SERVER_NAME'])) $serverName = $_SERVER['SERVER_NAME'];
|
||||
else if (isset($_SERVER['HTTP_HOST'])) $serverName = $_SERVER['HTTP_HOST'];
|
||||
else $serverName = $_SERVER['SERVER_ADDR'];
|
||||
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) {
|
||||
if ($_SERVER['SERVER_PORT'] == 443) {
|
||||
Configure::write('MISP.baseurl', sprintf('https://%s', $_SERVER['SERVER_ADDR']));
|
||||
Configure::write('MISP.baseurl', sprintf('https://%s', $serverName));
|
||||
} else {
|
||||
Configure::write('MISP.baseurl', sprintf('https://%s:%d', $_SERVER['SERVER_ADDR'], $_SERVER['SERVER_PORT']));
|
||||
Configure::write('MISP.baseurl', sprintf('https://%s:%d', $serverName, $_SERVER['SERVER_PORT']));
|
||||
}
|
||||
} else {
|
||||
if ($_SERVER['SERVER_PORT'] == 80) {
|
||||
Configure::write('MISP.baseurl', sprintf('http://%s', $_SERVER['SERVER_ADDR']));
|
||||
Configure::write('MISP.baseurl', sprintf('http://%s', $serverName));
|
||||
} else {
|
||||
Configure::write('MISP.baseurl', sprintf('http://%s:%d', $_SERVER['SERVER_ADDR'], $_SERVER['SERVER_PORT']));
|
||||
Configure::write('MISP.baseurl', sprintf('http://%s:%d', $serverName, $_SERVER['SERVER_PORT']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue