CloudFlare mod_cloudflare WHM EasyApache4 CloudLinux Cannot load modules/mod_cloudflare.so
Being a CloudFlare certified partner, all of my servers are running with CloudFlare WHM/cPanel plugin installed, as well as Railgun, but after upgrading one of my CentOS 6.9 servers to use EasyApache4, the real visitor IP was no longer showing in the access and error logs (CloudFlare IP was showing), and when attempting to restart Apache2 (httpd) I kept getting the “undefined symbol: ap_log_rerror” error, which CloudFlare and cPanel, were not very helpful at all in figuring out the problem … but I was able to figure it out, and here’s how to fix it
This was the error I kept constantly seeing whenever I would run service httpd configtest :
1 |
httpd: Syntax error on line 27 of /etc/apache2/conf/httpd.conf: Syntax error on line 1 of /etc/apache2/conf.modules.d/cloudflare.conf: Cannot load modules/mod_cloudflare.so into server: /etc/apache2/modules/mod_cloudflare.so: undefined symbol: ap_log_rerror |
Specifically the error being mod_cloudflare.so: undefined symbol: ap_log_rerror
Others have reported errors similar to this, which is really just a different module directory:
1 |
Starting httpd: httpd: Syntax error on line 230 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 |
I couldn’t for the life of me figure out what was causing this. I followed all the instructions to install the CloudFlare plugin for WHM/cPanel, and it even showed the mod_cloudflare module under the EasyApache4 modules list.
Luckily enough I found a forum post on CloudFlare’s website, and it turns out, that the cloudflare.conf file still remained from before the EasyApache4 upgrade, and in order to get mod_cloudflare working correct, I needed to run a few commands on the server.
First, you need to make sure that ea-apache24-devel is installed on the server, which can be done by running this command (this MUST be installed!):
1 |
yum install ea-apache24-devel |
After you have installed that package, we build the module manually, by running these commands:
1 2 3 |
cd /tmp wget https://www.cloudflare.com/static/misc/mod_cloudflare/mod_cloudflare.c apxs -a -i -c mod_cloudflare.c |
And that’s it! The apxs command will build and install the module for you, and then all you need to do is to check to make sure the config passes, and then you can restart Apache:
1 |
service httpd configtest |
If you get some warnings that look like this:
1 |
[so:warn] [pid 305662:tid 139794920114144] AH01574: module cloudflare_module is already loaded, skipping |
Chances are you still have old module configurations in either the old /etc/httpd/ directory, or somewhere else that is already loading the module. To find out where this is defined, you can run this command:
grep cloudflare -rI /etc/apache2/*
Make sure to check the /etc/httpd directory as well:
1 |
grep cloudflare -rI /etc/httpd/* |
Voila! Profit!
-
Sanjay Narayan