Posts

Showing posts with the label Cloudflare

CloudFlare And Logging Visitor IP Addresses Via In PHP

Answer : Extra server variables that are available to cloud flare are: $_SERVER["HTTP_CF_CONNECTING_IP"] real visitor ip address, this is what you want $_SERVER["HTTP_CF_IPCOUNTRY"] country of visitor $_SERVER["HTTP_CF_RAY"] $_SERVER["HTTP_CF_VISITOR"] this can help you know if its http or https you can use it like this: if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) { $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; } If you do this, and the validity of the visiting IP address is important, you might need to verify that the $_SERVER["REMOTE_ADDR"] contains an actual valid cloudflare IP address, because anyone can fake the header if he was able to connect directly to the server IP. Update : CloudFlare has released a module mod_cloudflare for apache, the module will log and display the actual visitor IP Addresses rather than those accessed by cloudflare! https://www.cloudfla...