4

I am trying to install mod_cloudflare for Apache using easyapache 4 on cPanel Server. I am running CentOS 7.2.

I have installed mod_cloudflare for EasyApache4 following the instructions under Option 2 here. After running the installer it said "Done. Please restart EasyApache 4". I then went into WHM -> EasyApache 4 and tried to find the server module, but it is not to be found. I clicked the "run system update" button and tried again, to no avail. Is there an easyapache service that needs to be restarted via the command line?

I am not a hosting provider so I have not tried the Cloudflare plugin for CPanel.

* Edit 4/9/2019 * Changing accepted answer to EasyCo's, as the original solution no longer works.

Kevin Roth
  • 338
  • 1
  • 5
  • 14

5 Answers5

7

Figured I'd throw my solution into the mix using Centos 6.9 with WHM/cPanel.

bash <(curl -s https://raw.githubusercontent.com/cloudflare/mod_cloudflare/master/EasyApache/installer.sh)
wget https://raw.githubusercontent.com/cloudflare/mod_cloudflare/master/mod_cloudflare.c
yum install ea-apache24-devel
apxs -a -i -c mod_cloudflare.c
rm /etc/apache2/conf.modules.d/mod_cloudflare.conf
service httpd restart

What's happening?

  1. We're using the cPanel installer.sh as suggested by Cloudflare but the compiled mod_cloudflare.so throws an error if you then run service httpd restart. Lets fix this.
  2. Download the source mod_cloudflare file.
  3. Ensure we have the correct EasyApache4 developer tools to build the mod_cloudflare module.
  4. Build and install extension module.
  5. Remove the new mod_cloudfare.conf file since we prefer the one that was generated and installed in step 1.
  6. Restart apache.

Note: The mod_cloudflare module will not show in EasyApache4. You can see it's enabled by running httpd -M | grep cloudflare and you should see something like cloudflare_module (shared).

References:

EasyCo
  • 2,036
  • 20
  • 39
  • The result I get from that `httpd ...` command is a nasty error, `httpd: Syntax error on line 259 of /etc/apache2/conf/httpd.conf: Syntax error on line 1 of /etc/apache2/conf.d/cloudflare.conf: Cannot load /usr/lib64/apache2/modules/mod_cloudflare.so into server: /usr/lib64/apache2/modules/mod_cloudflare.so: undefined symbol: ap_log_rerror`. Any suggestions? (This is after using the official method of installation, as referenced in OP) – inspirednz Mar 11 '18 at 20:48
  • So, I ran through your instructions, and this is the ONLY method I've found that actually works. The accepted solution, and all others I've found, did not work. Thanks for posting this. – inspirednz Mar 11 '18 at 21:00
  • @inspirednz No problem. What was causing the issue in your first comment? – EasyCo Mar 14 '18 at 00:07
  • The official method of installation installs a `mod-cloudflare.so` which apache doesn't like. I deleted that file, and then went with your method. Problem solved. – inspirednz Mar 14 '18 at 00:34
  • this may be obvious to some, or perhaps just situational, but httpd crashed after step 3, you'll need to continue through the rest of the steps and start httpd and all is golden. Adding this comment because had I known to expect this I wouldn't have had a near heart attack! – blindmikey Feb 28 '20 at 17:28
4

I found a solution that worked perfectly.

This github project installs the module and adds it into EasyApache so that future rebuilds keep the module active. This was the only solution I found that actually works for EasyApache 4. Everything else seems to be for EasyApache 3.

CloudFlare was not much help with this either, as they had suggested I contact my hosting provider for assistance.

Kevin Roth
  • 338
  • 1
  • 5
  • 14
  • 1
    Thanks. This worked for me. It may have been installed by cloudflare's instructions, but until I followed the instruction on the GitHub page it did not show up in Easy Apache 4 modules. And cloudflare support on this is terrible. Badly outdated instructions, and support staff has no idea. – jimlongo Oct 29 '17 at 18:35
  • This no longer works. That GitHub project is apparently no long maintained, and the repository it instructs to install the module from is down. Has been for quite some time. See this Issue (https://github.com/JPerkster/ea-apache24-mod_cloudflare/issues/10). The only solution I've found that works is the answer posted by EasyCo. In my opinion, that answer should be marked as the correct answer at this time. – inspirednz Mar 11 '18 at 21:01
2

I know this is a bit old now, but it's the first answer that shows up in google.

The official cloudflare answer does work, it just doesn't show up in the EA4 list of modules. However it is installed and working.

Seb
  • 21
  • 1
0

Just for others like me that reached here recently, mod_cloudflare module is deprecated and there is a native module for apache [mod_remoteip]. I can see it in EasyApache (apache module section). Also There is a manual here to install & config :

https://support.cloudflare.com/hc/en-us/articles/200170786-Restoring-original-visitor-IPs

with this module you can see Client IP through

$_SERVER['REMOTE_ADDR']

And there is no need to

$_SERVER['HTTP_CF_CONNECTING_IP']
Kranchi
  • 73
  • 1
  • 9
-1

Instructions for installing mod_cloudflare on cPanel with EasyApache4 can be found here: https://support.cloudflare.com/hc/en-us/articles/206175737-How-do-I-restore-original-visitor-IP-with-EasyApache-cPanel-

bash <(curl -s https://raw.githubusercontent.com/cloudflare/mod_cloudflare/master/EasyApache/installer.sh)
jwineman
  • 161
  • 1
  • 7
  • 1
    The way you suggested it was already mentioned in the link provided by OP. When you did that, the output will be "Done. Please restart EasyApache 4." That's exactly his problem because even after you got it installed using that command, the option to enable mod_clouodflare in EasyApache4 is not appearing. – James A Feb 02 '17 at 02:33