8000 Unable to profile URL behind CDN/Load Balancer (e.g. Cloudflare) · Issue #100 · preinheimer/xhprof · GitHub
[go: up one dir, main page]

Skip to content

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

Open

Description

@tperalta82

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;

}

Activity

  1. changed the title [-]In case a request is made on a URL that is behind Cloudflare, no profiling will be made by request[/-] [+]Unable to profile URL behind CDN/Load Balancer (e.g. Cloudflare)[/+] on Oct 11, 2016
  2. aik099 commented on Oct 11, 2016

    @aik099
    Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0