Using Mollom with a Drupal 5.x server that is after a proxy server (load balancer o squid server) doesn't use the real ip source from a possible spammer.
In the 5.x-1.x version, the function _mollom_ip_address does not consider the existence of the X-Forwarded-For variable as in Drupal 6.x that use the ip_address() API function.

Comments

moshe weitzman’s picture

This is really a limitation of D5 core as well. You might want to simply hack mollom_ip_address() or upgrade to d6.

jcmarco’s picture

Status: Active » Closed (fixed)
patrickfgoddard’s picture

I was having this issue too: Mollom entries in logs were only showing load balancer IP.

My "hack" is to cut and paste ip_address function from D6: http://api.drupal.org/api/function/ip_address/6 to replace the guts of _mollum_ip_address()

This is the result of trying to figure out why a legitimate (anonymous) comment got marked as spam (thus the user unable to post anything.) I'm hoping modifying the above function is a step in right direction.

EDIT:

On second pass, I had to manually add $reverse_proxy and $reverse_proxy_addresses (since in D6 has this option in settings.php file).

So here is my hacked function:

function _mollom_ip_address() {
  
  // ORIGINAL (just one line)
  //return $_SERVER['REMOTE_ADDR'];
  static $ip_address = NULL;
  $reverse_proxy = TRUE;
  $reverse_proxy_addresses = array('1.2.3.4');
  if (!isset($ip_address)) {
    $ip_address = $_SERVER['REMOTE_ADDR'];
    if ($reverse_proxy && array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
      // 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());
      if (!empty($reverse_proxy_addresses) && in_array($ip_address, $reverse_proxy_addresses, TRUE)) {
        // If there are several arguments, we need to check the most
        // recently added one, i.e. the last one.
        $ip_address = array_pop(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']));
      }
    }
  }
  return $ip_address;
}