title: How can I get the user's IP while using both CloudFlare and MaxMind's GeoIP with mod_geoip?
body: <p>CloudFlare provides the user's country from the originating IP but I need location on a city level so I've added MaxMind's GeoCityLite using the mod_geoip Apache script.</p>
  
  <p>The problem is now to get the IP in a php variable, I'm using something like</p>
  
  <pre><code>$country = apache_note("GEOIP_COUNTRY_CODE");
  </code></pre>
  
  <p>This is great but the IP mod_geoip is using is the CloudFlare DNS, not the end user.  CloudFlare offers the server variable HTTP_CF_CONNECTING_IP to use the end-user IP but how do I use THAT variable/IP in the mod_geoip?</p>
  
  <p>Can this be done with a few lines in htaccess?</p>
  
  <p>Edit: I have a workaround using the php API for geoip which is easy but the benchmarks using the apache lookup of the php api is much much better so I'd rather find this solution.</p>