A guide on how to install mod_cloudflare for Apache on Ubuntu from the terminal in a few simple steps and verify its activation.

What is Cloudflare

Cloudflare is a global network service aimed at protecting, speeding up and optimizing online content. Cloudflare acts as a
reverse proxy
, that is, it stands between web applications and the outside world so that traffic is properly routed and policed.

The two most important features offered by Cloudflare are.

  1. The defense against hacker attacks and infiltration
  2. The implementation of a file caching and compression system that speeds up websites by up to 30 percent

What mod_cloudflare for Apache is for

mod_cloudflare is a module for Apache, officially developed by Cloudflare, that replaces the remote_ip variable in user logs with thecorrect remote IP sent by CloudFlare. The module only performs IP replacement for requests from CloudFlare IPs by default.

In addition to this, the extension also sets the HTTPS environment variable to “on” in cases where flexible SSL is in use. This prevents software such as WordPress from being hacked by flexible SSL.

WARNING. The steps below should be performed by experienced people as they are potentially dangerous and could damage the server. If you do not know what you are doing you can request a free quote.

Install mod_cloudflare on Linux Ubuntu

Here is how to install mod_cloudflare for Apache on Ubuntu via SSH terminal.

  1. import the GPG key on Ubuntu
    curl -C - https://pkg.cloudflare.com/pubkey.gpg | sudo apt-key add - 
  2. create the PPA file
    echo "deb http://pkg.cloudflare.com/ `lsb_release -cs` main" | sudo tee /etc/apt/sources.list.d/cloudflare.list
  3. update the apt cache and install the libapache2-mod-cloudflare package in the system
    sudo apt update 
    sudo apt install libapache2-mod-cloudflare
  4. restart Apache services
    sudo service apache2 restart
  5. verify that the newly installed module is listed in the Apache module list
    sudo apache2ctl -M

Linux Support Quote

    Contact us for a free quote