CloudFlare offers the user's country in the coming initially from IP however i need location on the city level so I have added MaxMind's GeoCityLite while using mod_geoip Apache script.

The issue is now to obtain the IP inside a php variable, I am using something similar to

$country = apache_note("GEOIP_COUNTRY_CODE");

This really is great however the IP mod_geoip is applying may be the CloudFlare DNS, not the consumer. CloudFlare provides the server variable HTTP_CF_Hooking up_IP to make use of the finish-user IP but how do you use THAT variable/IP within the mod_geoip?

Is this completed with a couple of lines in htaccess?

Edit: I've got a workaround while using php API for geoip that is easy however the benchmarks while using apache research from the php api is a lot far better so I'd rather find this solution.

To obtain a user's Ip saved inside a variable like $ip, it can be done inside a couple ways:

$ip = $_SERVER['REMOTE_ADDR'];

or

$ip = getenv('REMOTE_ADDR');

Cloudflare comes with an Apache extension mod_cloudflare (https://github.com/cloudflare/CloudFlare-Tools) that we believe replaces the Cloudflare IP with the most appropriate one.

Whether it's loaded before mod_geoip it could work for the way mod_geoip works.

You'll need root use of install mod_cloudflare though.