Integrating fail2ban with Cloudflare API v4 instead of default v1


#1

So I found a very useful blog post that explains how to switch your fail2ban from using the Cloudflare v1 API to using the Cloudflare v4 API. The Cloudflare v4 API is so much faster than the v1 API. Getting the config posted in here without it becoming a formatting diaster is too hard so I’m just going to let you read the blog post I linked earlier. Tell me what you think about it. It’s pretty awesome how Cloudflare has improved their API in v4 and now all of you can experience the benefits with ease :smiley:


Cloudflare IP Firewall Limitations?
#2

Thanks for that i used the fail2ban default cloudflare action which is a bit dated so this makes it easier

edit:

tried modifying the action ban to add the filter name <name> to notes section but doesn’t seem to work. If anyone has any ideas here’s what I tried https://gist.github.com/centminmod/8e224ec689d8cf46e40b89b4d9e9d02f

for now seems to be work okay without passing filter name to Cloudflare firewall’s notes https://github.com/centminmod/centminmod-fail2ban#cloudflare-v4-api in that it shows up in cloudflare firewall access rules for blocking server IP = 149.xxx.xxx.xxx

curl -I http://domain.com/wp-login.php 
HTTP/1.1 403 Forbidden
Date: Sat, 13 May 2017 05:22:01 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Set-Cookie: __cfduid=d34a309e3527a91971491fc853424dbca1494652921; expires=Sun, 13-May-18 05:22:01 GMT; path=/; domain=.domain.com; HttpOnly
Cache-Control: max-age=15
Expires: Sat, 13 May 2017 05:22:16 GMT
X-Frame-Options: SAMEORIGIN
Server: cloudflare-nginx
CF-RAY: 35e32d7813e63f95-YUL

149.xxx.xxx.xxx is blocked ip listing


#3

Glad to see you’re enjoying it. The v4 API is so much faster :smiley:


#4

thanks working very well with my fail2ban implementation