CSF & Cloudflare

Dudik

Verified User
Joined
Feb 5, 2012
Messages
20
Hi everyone,

I am facing an issue that I am not able to figure out how to solve.

I am using Almalinux 8 as OS, Cloudflare as proxy and CSF as firewall.
I have Cloudflare IPs in csf.ignore and if I block an IP inside csf.deny, that IP is blocked for all connections to the servers excluding HTTP

I have checked the access logs for the domain I am testing with and that IP comes as first entry, so the IP in Apache (and Nginx) is stored ccorrectlly, it is not showing the Clouflare one, so in theory CSF should be blocking those but it is not.

Has anyone faced a similar issue?
I've searched the forum and I saw some instances of the same setup, but not a solution.

Is there anything specific I need to configure in DA/CSF/Cloudflare to have CSF be able to block such connections?

Thanks in advance
 
You can't blocking behind proxy.
CSF have option to integrate with cloudflare API to add blocked IP to cloudflare in realtime.
 
Can you explain more please?
I found something about mod_cloudflare but I understand it was replaced with mod_remoteip.

In addition, are there other options besides CSF to work with Cloudflare?
 
27. CloudFlare
##############

This features provides interaction with the CloudFlare Firewall.

As CloudFlare is a reverse proxy, any attacking IP addresses (so far as
iptables is concerned) come from the CloudFlare IP's. To counter this, an
Apache module (mod_cloudflare) is available that obtains the true attackers
IP from a custom HTTP header record (similar functionality is available
for other HTTP daemons.

However, despite now knowing the true attacking IP address, iptables cannot
be used to block that IP as the traffic is still coming from the CloudFlare
servers.

CloudFlare have provided a Firewall feature within the user account where
rules can be added to block, challenge or whitelist IP addresses.

Using the CloudFlare API, this feature adds and removes attacking IPs from that
firewall and provides CLI (and via the UI) additional commands.

There are several restrictions to using this feature:

1. All lfd blocks will be temporary blocks so that csf/lfd can keep blocks in
sync with CloudFlare

2. Automatic blocks via lfd are limited to LF_MODSEC and LF_CXS triggers as
only through these can the domain name be determined. Any users that own
domains that are involved in the trigger will get a block in their
CloudFlare Firewall. Additionally, any users with the special case "any"
will also get blocks

3. The temporary/permanent config of the lfd settings are ignored and CF_TEMP
is used instead

4. LF_TRIGGER must not be used, the feature will not work with it enabled

5. mod_cloudflare or similar must be used to report real IP in the Apache logs

6. URLGET must be set to 2 (i.e. LWP) must be used

7. If PERMBLOCK is used, the last tempblock will remain and never be cleared.
So any CloudFlare Firewall entries must be manually cleared in CloudFlare
or via CLI

8. There are restrictions imposed by CloudFlare to the number of rules that
can be created depending on the type of account used. See
https://goo.gl/ssGu7v for more information

9. When restarting csf, any old temporary blocks will still be created for lfd
to clear when it restarts

10. All interaction with CloudFlare is at User-level, not Zone-level

11. If using the CloudFlare cPanel user plugin, it must be v7+

CF_TEMP should be configured taking into account the maximum number of rules
that the CloudFlare account allows: https://goo.gl/ssGu7v

All CloudFlare users for the domains that are involved in LF_MODSEC and
LF_CXS triggers will have a CloudFlare rule added. Any CloudFlare account
configured to use the special case "any" field value in csf.cloudflare will
have a CloudFlare rule added regardless of domain.

NOTE: You should always list the CloudFlare IP addresses in /etc/csf/csf.ignore
to prevent them from being blocked by lfd from https://www.cloudflare.com/ips/
 
Back
Top