For Incapsula CDN user
-
Incapsula CDN is similar to the cloudflare so to make it work with Incapsula I have added this code to the .htninja
<?php
/*
+=====================================================================+
| NinjaFirewall optional configuration file |
| |
| See: http://nintechnet.com/nfwp/1.1.3/ |
| |
+=====================================================================+
*/// Users of Cloudflare CDN:
if (isset($_SERVER[‘HTTP_X_FORWARDED_FOR’]))
{
$_SERVER[‘REMOTE_ADDR’] = $_SERVER[‘HTTP_X_FORWARDED_FOR’];
}is this correct or I should change it to
<?php
/*
+=====================================================================+
| NinjaFirewall optional configuration file |
| |
| See: http://nintechnet.com/nfwp/1.1.3/ |
| |
+=====================================================================+
*/// Users of Cloudflare CDN:
/**
* This file should be included at the beginning of your PHP code
*
* It changes the value of $_SERVER[‘REMOTE_ADDR’], to the value provided in the Incap-Client-IP header.
* If such a value is not provided, or is not valid – no change is made.
*///name of HTTP header with the initial client IP address
define(‘HEADER_NAME’,’HTTP_INCAP_CLIENT_IP’);try {
//stop process if there is no header
if (empty($_SERVER[HEADER_NAME])) throw new Exception(‘No header defined’, 1);//validate header value
if (function_exists(‘filter_var’)) {
$ip = filter_var($_SERVER[HEADER_NAME], FILTER_VALIDATE_IP);
if (false === $ip) throw new Exception(‘The value is not a valid IP address’, 2);
}
else {
$ip = trim($_SERVER[HEADER_NAME]);
if (false === preg_match(‘/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/’, $ip)) throw new Exception(‘The value is not a valid IP address’, 2);
}//At this point the initial IP value is exist and validated
$_SERVER[‘REMOTE_ADDR’] = $ip;
} catch (Exception $e) {}Code provided by incapsula to get correct ip
http://support.incapsula.com/hc/en-us/articles/200628020-General-PHP-Applications
https://github.com/wp-plugins/incapsula/blob/master/incapsula.php
The topic ‘For Incapsula CDN user’ is closed to new replies.