Last modified: 2013-03-13 10:39:47 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 12690 - wfGetForwardedFor (X-Forwarded-For) doesn't always works
wfGetForwardedFor (X-Forwarded-For) doesn't always works
Status: NEW
Product: MediaWiki
Classification: Unclassified
User login and signup (Other open bugs)
All All
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-need-review
Depends on:
  Show dependency treegraph
Reported: 2008-01-19 13:59 UTC by Petya Kohts
Modified: 2013-03-13 10:39 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Description Petya Kohts 2008-01-19 13:59:03 UTC
On my installation mediawiki doesn't correctly determines
X-Forwarded-For header and displays IP address of Squid Server
insted of actual client IP address.

Apache 2.0.54
PHP 5.2.1

Here's the patch which corrects the error for my installation:

--- ProxyTools.php.orig 2007-06-29 05:19:14.000000000 +0400
+++ ProxyTools.php      2008-01-19 12:50:10.000000000 +0300
@@ -15,12 +15,19 @@
                $set = apache_request_headers();
                $index = 'X-Forwarded-For';
                $index2 = 'Client-ip';
-       } else {
-               // Subject to spoofing with headers like X_Forwarded_For
-               $set = $_SERVER;
-               $index = 'HTTP_X_FORWARDED_FOR';
-               $index2 = 'CLIENT-IP';
+           if( isset( $set[$index] ) ) {
+               return $set[$index];
+           } else if( isset( $set[$index2] ) ) {
+               return $set[$index2];
+           }
+       // Subject to spoofing with headers like X_Forwarded_For
+       $set = $_SERVER;
+       $index = 'HTTP_X_FORWARDED_FOR';
+       $index2 = 'CLIENT-IP';
        #Try a couple of headers
        if( isset( $set[$index] ) ) {
                return $set[$index];
Comment 1 Andre Klapper 2013-03-13 10:39:47 UTC
Hi Petya! Sorry that nobody has taken a look at this report yet and given feedback.

Thanks for your patch!

You are welcome to use Developer access
to submit this as a Git branch directly into Gerrit:

Putting your branch in Git makes it easier to review it quickly.
Thanks again! We appreciate your contribution.

Note You need to log in before you can comment on or make changes to this bug.