Using an out-of-the-box MediaWiki installation in the Amazon EC2 environment behind an Elastic Load Balancer and CloudFlare as a DNS provider, every user’s IP address will show as the load balancer’s IP address. For obvious reasons, this is not ideal, but is easy to remedy.
First, add $wgUsedPrivateIPs = true; to your LocalSettings.php if not already present.
Then, the TrustedXFF MediaWiki extension needs to be installed, and the CloudFlare IP addresses should be added to the trusted-hosts.txt document. The extension handles the IP range syntax used by CloudFlare, so a direct copy of the IPv4 text file is sufficient. In addition, add your elastic load balancer IP address/range so that proxy will also be whitelisted.
Edit generate.php – find the location where a “Range too big” error could be thrown. On the line above this, change the 8192 limit to 132192. This will ensure all CloudFlare IP addresses are added. If you run into performance problems later, start removing the lesser-used ISPs from the bottom of the trusted-hosts.txt document.
If your server is not live, add the require_once line to your LocalSettings.php. Then, run the generate.php script that came with the extension.
If your server is live, you will need to specify the installation location on the command line (mediawiki_directory/cache/trusted-xff.cdb by default).
The generate.php file will create a database of IP addresses that will be used as trusted proxies. Since you added CloudFlare’s IP addresses, you should now see the actual IP address of the user.
You may consider running generate.php periodically to receive updated IP addresses.
The procedure above allows you to get the actual IP address of the user without modifying core MediaWiki code, as the CloudFlare FAQ suggests.