marxjohnson/moodle-block_lanonly — Issue #2: Don't work with reverse Proxy 
Author: cazin
Created: 2012-02-14 12:54:09+00:00
State: open

The "plug in" don't work wirh reverse proxy , It works only with a direct access .

Proxy should be detect with something like that :

if HTTP_X_FORWARDED_FOR or HTTP_CLIENT_IP exist :

function get_ip () {
if ( isset ( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
elseif ( isset ( $_SERVER['HTTP_CLIENT_IP'] ) ) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}

regards,

Christophe