Client IP behind proxy (#665)

Function added for IP filtering when the filemanager is hosted behind a web proxy.

I've added a function for this to the file, not sure how else to implement it since everything is one file.
This commit is contained in:
jicho 2022-02-12 08:58:26 +01:00 committed by GitHub
parent ad30a3a1f3
commit e474ade92b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -244,8 +244,19 @@ if (isset($_GET['logout'])) {
}
// Validate connection IP
if($ip_ruleset != 'OFF'){
$clientIp = $_SERVER['REMOTE_ADDR'];
if ($ip_ruleset != 'OFF') {
function getClientIP() {
if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
return $_SERVER["HTTP_X_FORWARDED_FOR"];
}else if (array_key_exists('REMOTE_ADDR', $_SERVER)) {
return $_SERVER['REMOTE_ADDR'];
}else if (array_key_exists('HTTP_CLIENT_IP', $_SERVER)) {
return $_SERVER['HTTP_CLIENT_IP'];
}
return '';
}
$clientIp = getClientIP();
$proceed = false;