Learn how to install mod_cloudflare and log your visitor’s original IP address at your origin server. Learn how to remove mod_cloudflare.
For example, if you install applications that depend on the incoming IP address of the original visitor, a Cloudflare IP address is logged by default. The original visitor IP address appears in an appended HTTP header called CF-Connecting-IP. With the mod_cloudflare tool, you can log the original visitor IP address at your origin server.
The diagram below illustrates the different ways that IP addresses are handled with and without Cloudflare.
There are two methods for installing mod_cloudflare: by downloading packets or scripts from our technical resources, or by adding code to your origin web server.
Downloading packets or scripts
There are four options for installing mod_cloudflare using packets or scripts:
2. Via cPanel Servers
3. Manual Installation: RedHat/CentOS/CloudLinux
4. Manual Installation: Debian/Ubuntu
For more information on these four options, follow the installation steps described on our Downloads page.
Adding code to your origin web server
If you can't install mod_cloudflare, or if there is no Cloudflare plugin available for your content management system platform to restore original visitor IP, add this code to your origin web server in or before the <body> tag on any page that needs the original visitor IPs:
<?php if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];>
To remove mod_cloudflare, you should comment out the Apache config line that loads mod_cloudflare.
This varies based on your Linux distribution, but for most people, if you look in
/etc/apache2, you should be able to search to find the line:
Comment or remove this line, then restart apache, and mod_cloudflare should be gone.
If you are running Ubuntu or Debian, you should see a
Delete this file to remove mod_cloudflare, then restart Apache.
Mod_cloudflare is installed by modifying the nginx configuration file
nginx.conf with the
To remove mod_cloudflare you should comment or remove this line, then restart nginx, and mod_cloudflare should be gone.