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
, 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.
- The defense against hacker attacks and infiltration
- 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.
Install mod_cloudflare on Linux Ubuntu
Here is how to install mod_cloudflare for Apache on Ubuntu via SSH terminal.
- import the GPG key on Ubuntu
curl -C - https://pkg.cloudflare.com/pubkey.gpg | sudo apt-key add -
- create the PPA file
echo "deb http://pkg.cloudflare.com/ `lsb_release -cs` main" | sudo tee /etc/apt/sources.list.d/cloudflare.list
- update the apt cache and install the libapache2-mod-cloudflare package in the system
sudo apt update sudo apt install libapache2-mod-cloudflare
- restart Apache services
sudo service apache2 restart
- verify that the newly installed module is listed in the Apache module list
sudo apache2ctl -M