Last modified: 2013-03-13 10:39:47 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];
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 https://www.mediawiki.org/wiki/Developer_access to submit this as a Git branch directly into Gerrit: https://www.mediawiki.org/wiki/Git/Tutorial Putting your branch in Git makes it easier to review it quickly. Thanks again! We appreciate your contribution.