Skip to content

Commit 0344bc5

Browse files
author
Rajko Albrecht
committed
Ticket #5236
Start checks against local sites list for allowed reverse proxy forwards
1 parent b26dcd0 commit 0344bc5

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

interface/lib/app.inc.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,17 +335,28 @@ public function tpl_defaults() {
335335

336336
private function get_cookie_domain() {
337337
$proxy_panel_allowed = $this->getconf->get_security_config('permissions')['reverse_proxy_panel_allowed'];
338+
if ($proxy_panel_allowed == 'all') {
339+
return '';
340+
}
338341
$cookie_domain = (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST']);
339342
// Workaround for Nginx servers
340343
if($cookie_domain == '_') {
341344
$tmp = explode(':',$_SERVER["HTTP_HOST"]);
342345
$cookie_domain = $tmp[0];
343346
unset($tmp);
344347
}
345-
$this->log("Server: ".print_r($_SERVER,true));
346-
if ($proxy_panel_allowed == 'all') {
347-
return '';
348+
if($proxy_panel_allowed == 'sites') {
349+
$forwarded_host = (isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : null );
350+
if($forwarded_host !== null && $forwarded_host !== $cookie_domain) {
351+
$sql = "SELECT domain_id from web_domain where domain = '$forwarded_host'";
352+
$recs = $this->db->queryOneRecord($sql);
353+
if($recs !== null) {
354+
$cookie_domain = $forwarded_host;
355+
}
356+
unset($forwarded_host);
357+
}
348358
}
359+
349360
return $cookie_domain;
350361
}
351362

0 commit comments

Comments
 (0)