Cloudflare is an content delivery network service act as a reverse proxy. It is widely used by the websites to serve content through cloudflare global network. When the website traffic is routed through cloudflare, the backend servers logged cloudflare ip address instead of original visitor ip address.
This tutorial will help you to enable Apache mod_cloudflare module on a Ubuntu system. Which will log original visitor IP address to logs.
Install mod_cloudflare for Apache
The cloudflare provides an official module for the Apache server to capture real ip address. You need to enable the PPA of cloudflare module to your Ubuntu system.
curl -C - https://pkg.cloudflare.com/pubkey.gpg | sudo apt-key add - echo "deb http://pkg.cloudflare.com/ `lsb_release -cs` main" | sudo tee /etc/apt/sources.list.d/cloudflare.list
Next, update Apt cache and install libapache2-mod-cloudflare package on your Ubuntu system.
sudo apt-get update sudo apt-get install libapache2-mod-cloudflare
Once the installation completed, restart Apache2 service and check the active modules using the following commands.
sudo service apache2 restart sudo apache2ctl -M
In this tutorial, you have learned to configure cloudflare module to Apache on Ubuntu system.