If anyone has the same problem.
Check the headers sent by the CDN
print_r($_SERVER)
find out in what header they send the visitor's IP and change the value of $_SERVER['REMOTE_ADDR'] and $_SERVER['HTTP_X_FORWARDED_FOR'] with the actual IP at the top of your code (for exemple config/config.inc.php)
Quoteif (isset($_SERVER['IP_SENT_BY_CDN']) && $_SERVER['IP_SENT_BY_CDN']!='') {
$_SERVER['HTTP_X_FORWARDED_FOR'] = $_SERVER['IP_SENT_BY_CDN'];
$_SERVER['REMOTE_ADDR'] = $_SERVER['IP_SENT_BY_CDN'];
}
This might solve it.