IP address identification not broad enough

Gábor Hojtsy - May 14, 2008 - 14:00
Project:Drupal
Version:6.x-dev
Component:base system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:patch (code needs review)
Description

From an email from Benjamin Schrauwen

> As for the 172 issue - this has driven me crazy frankly - has nothing to do with mollom. When I switched hosts about 90 days ago, all of the comments, trackbacks, everything said the 172 address. No one on drupal forums, email support list could seem to help me. Finally my hosting provider told me it's because I am hosted in the cloud and that I have to pass along another code instead of asking for the ip normally. The code is:
> $_SERVER['HTTP_X_CLUSTER_CLIENT_IP']
>
> So I went into trackback module and comment module and changed the code in the actual module. And it started working great immediately - I saw the ip addresses correctly. Then yesterday, I looked again and it's back to 172 again. Now I can't figure out why. Any ideas would be very much appreciated.

Yes, getting a correct IP address of a HTTP connection seems to be an
issue all over the place. I found this list of variables which might
hold the visitor's IP address:

HTTP_CLIENT_IP
HTTP_X_FORWARDED_FOR
HTTP_X_CLUSTER_CLIENT_IP
HTTP_PROXY_USER
REMOTE_ADDR

Could you try too see which works.

With kind regards,
Benjamin.

#1

Dries - May 18, 2008 - 20:28

#2

Dries - May 18, 2008 - 20:42
Version:6.x-dev» 7.x-dev
Status:active» patch (code needs review)

This is a problem for Mollom so I came up with a fix for DRUPAL-6 and CVS HEAD.

I don't have a cluster environment so I can't actually test the patch. I doubt anyone has.

AttachmentSize
cluster-ip.patch1.75 KB

#3

Dries - June 25, 2008 - 10:01

*My turn to bump a patch*

#4

R.Muilwijk - June 25, 2008 - 22:09

Adds a test for the ip address function

AttachmentSize
cluster-ip.patch4.44 KB

#5

keith.smith - June 26, 2008 - 01:50

Minor style issue: if you have to reroll, please end comments with periods so that they form complete sentences. The variations of IP, ip and Ip should all probably be standardized as IP (I guess).

#6

Dries - June 26, 2008 - 11:30
Version:7.x-dev» 6.x-dev
Status:patch (code needs review)» patch (reviewed & tested by the community)

I've made the changes suggested by Keith and committed the patch to CVS HEAD. The bootstrap.inc part should go into DRUPAL-6 as well as we're not always capturing the right address.

#7

John Morahan - June 26, 2008 - 20:39
Status:patch (reviewed & tested by the community)» patch (code needs work)

I don't know what happens in a cluster environment, but under normal circumstances this header can be spoofed.

#8

grandcat - June 26, 2008 - 20:45

That's right, I'm of the same opinion like John Morahan. If it's a well configured cluster, the real IP should be passed through to the servers behind the proxy. And so, it's their task to perform this step. And I'm also sure that all these servers like APACHE or LIGHTTPD support this feature.

#9

Dries - July 4, 2008 - 22:54
Status:patch (code needs work)» fixed

You were right. The brackets were not placed properly. I fixed this in CVS HEAD. Thanks.

#10

Gábor Hojtsy - July 5, 2008 - 15:23

Hm, what HEAD? What would be the patch to commit to 6.x?

#11

Gábor Hojtsy - July 5, 2008 - 15:23
Status:fixed» patch (code needs work)

#12

John Morahan - August 21, 2008 - 21:44
Status:patch (code needs work)» patch (code needs review)

This one, I guess? This is a combination of #4 (minus the test) and http://cvs.drupal.org/viewvc.py/drupal/drupal/includes/bootstrap.inc?r1=...

AttachmentSize
ip_address.patch3 KB

#13

John Morahan - August 21, 2008 - 21:52

Here's one with the style changes from #5 too.

AttachmentSize
ip_address.patch3 KB
 
 

Drupal is a registered trademark of Dries Buytaert.