xhprof icon indicating copy to clipboard operation
xhprof copied to clipboard

Unable to profile URL behind CDN/Load Balancer (e.g. Cloudflare)

Open tperalta82 opened this issue 9 years ago • 1 comments

On header.php: if ($controlIPs === false || in_array($_SERVER['REMOTE_ADDR'], $controlIPs) || PHP_SAPI == 'cli')

This will not be vaild if behind reverse proxy e.g: cloudflare / varnish / others

Should be something like this: function getUserIP() { $client = @$_SERVER['HTTP_CLIENT_IP']; $forward = @$_SERVER['HTTP_X_FORWARDED_FOR']; $remote = $_SERVER['REMOTE_ADDR'];

if(filter_var($client, FILTER_VALIDATE_IP))
{
    $ip = $client;
}
elseif(filter_var($forward, FILTER_VALIDATE_IP))
{
    $ip = $forward;
}
else
{
    $ip = $remote;
}

return $ip;

}

tperalta82 avatar Oct 11 '16 16:10 tperalta82

Agreed. Please send a PR, where IP address detection will be made using new function.

aik099 avatar Oct 11 '16 18:10 aik099