Skip to content

How To Install mod_cloudflare for Apache on Ubuntu

Advertisement

Cloudflare is a content delivery network service that acts as a reverse proxy. It is widely used by websites to serve content through Cloudflare’s global network. When the website traffic is routed through Cloudflare, the backend servers logged the Cloudflare IP address instead of the original visitor IP address.

This tutorial will help you to enable Apache mod_cloudflare module on a Ubuntu system. Which will log the original visitor IP address to logs.

Install mod_cloudflare for Apache

Cloudflare provides an official module for the Apache server to capture real IP addresses. You need to enable the PPA of the Cloudflare module to your Ubuntu system.

  1. Firstly import the GPG key into your system:
    curl -C - https://pkg.cloudflare.com/pubkey.gpg | sudo apt-key add - 
    
  2. Then create the PPA file with the below command:
    echo "deb http://pkg.cloudflare.com/ `lsb_release -cs` main" | sudo tee /etc/apt/sources.list.d/cloudflare.list 
    
  3. Next, update Apt cache and install the libapache2-mod-cloudflare package on your Ubuntu system.
    sudo apt update 
    sudo apt install libapache2-mod-cloudflare 
    
  4. Once the installation is completed, restart the Apache2 service and check the active modules using the following commands.
    sudo service apache2 restart 
    
  5. Then list all the modules from the Apache web server.
    sudo apache2ctl -M 
    

    How to Install CloudFlare Module in Apache

Conclusion

In this tutorial, you have learned to configure the Cloudflare module to Apache on the Ubuntu system.

Rahul

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

7 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top