Block X-Forwarded-IP from developer portal

Hi,

I am trying to block the X-Forwarded-IP coming from the Load Balancer toward developer portal.I am using drupal7 module named "flood control" but this module does not block the specific IP therefore if one developer get "IP block message " after failed of number of attempts all developer face this issue.

How do I do this?

Please help.

0 1 117
1 REPLY 1

I have resolved this issue which i was facing by hook method which i mentioned below and how i can Block the X-Forwarded-IP.

function hook_ip_address() {
  $ip_address = &drupal_static(__FUNCTION__);


  if (!isset($ip_address)) {
   //$ip_address = $_SERVER['REMOTE_ADDR'];
     $ip_address =$_SERVER['HTTP_X_FORWARDED_FOR'];
    if (variable_get('reverse_proxy', 0)) {
      $reverse_proxy_header = variable_get('reverse_proxy_header', 'HTTP_X_FORWARDED_FOR');
      if (!empty($_SERVER[$reverse_proxy_header])) {
        // If an array of known reverse proxy IPs is provided, then trust
        // the XFF header if request really comes from one of them.
        $reverse_proxy_addresses = variable_get('reverse_proxy_addresses', array());


        // Turn XFF header into an array.
        $forwarded = explode(',', $_SERVER[$reverse_proxy_header]);


        // Trim the forwarded IPs; they may have been delimited by commas and spaces.
        $forwarded = array_map('trim', $forwarded);


        // Tack direct client IP onto end of forwarded array.
        $forwarded[] = $ip_address;


        // Eliminate all trusted IPs.
        $untrusted = array_diff($forwarded, $reverse_proxy_addresses);


        if (!empty($untrusted)) {
          // The right-most IP is the most specific we can trust.
          $ip_address = array_pop($untrusted);
        }
        else {
          // All IP addresses in the forwarded array are configured proxy IPs
          // (and thus trusted). We take the leftmost IP.
          $ip_address = array_shift($forwarded);
        }
      }
    }
  }


  return $ip_address;
}




Note:
 I just comment the above line and make little change.
  //$ip_address = $_SERVER['REMOTE_ADDR'];
     $ip_address =$_SERVER['HTTP_X_FORWARDED_FOR'];