Log and display correct visitor ip when using cloudflare

Logging Real Visitor IP Addresses: mod_cloudflare for Apache httpd
Because Cloudflare acts as a proxy, you will notice changes to the way that your website visitors’ IP addresses are displayed both in your server logs and web applications – notably that all access appears to be coming from Cloudflare IP addresses. You can read more about the reasons for this in our knowledge base article.

You can change this behavior and log & display the actual visitor IP addresses by using mod_cloudflare.

Install mod_cloudflare:
Download appropriate Debian .deb file from https://www.cloudflare.com/technical-resources/#mod_cloudflare
Eg:

wget https://www.cloudflare.com/static/misc/mod_cloudflare/debian/mod_cloudflare-jessie-amd64.latest.deb
dpkg -i mod_cloudflare-jessie-amd64.latest.deb

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.