Cloudflare Firewall Rules – How to Block Bots and Securing WordPress

If you use CloudFlare services then you must know that you can filter out much of the useless traffic and even secure your site from hackers attacks!

I will not go into very technical details, because this article is dedicated to those already familiar with CloudFlare and have some idea about how to configure filters for the CF firewall.

So, here are some simple rules to filter out some of the useless traffic and attacks on the site, especially for those who have wordpress installed.

CloudFlare Firewall Rule

Annoying Bot – Action: Block

(http.user_agent contains "ahrefs") or (http.user_agent eq "grapeshot") or (http.user_agent eq "msnbot") or (http.user_agent eq "yandex") or (http.user_agent eq "dotbot") or (http.user_agent eq "semrush") or (http.user_agent eq "yahoo") or (http.user_agent eq "mail.ru") or (http.user_agent eq "bing") or (http.user_agent eq "baidu") or (http.user_agent eq "apple") or (http.user_agent eq "archive.org")

China Bot – Action: Block

(http.user_agent contains "Mb2345Browser") or (http.user_agent contains "LieBaoFast") or (http.user_agent contains "MicroMessenger") or (http.user_agent contains "zh_CN") or (http.user_agent contains "NetType/WIFI") or (http.user_agent contains "zh-CN")

Invalid Request (Automated Bots Tool For Hackers) – Action: Block

(http.user_agent contains "Nmap") or (http.user_agent eq "-") or (http.user_agent contains "masscan") or (http.user_agent contains "curl") or (http.user_agent contains "ZmEu") or (http.request.uri.path contains "scripts/setup.php") or (http.user_agent contains "python")

WP-Login Atack Bot – Action: Block

(http.user_agent eq "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0") or (http.user_agent contains "PHP/7.2.8")

WP-Login/Admin CAPTCHA – Action: Challenge (Captcha)

(http.request.uri.path contains "/xmlrpc.php") or (http.request.uri.path contains "/wp-login.php")

The first four rules can be practically concatenated (unify), so as not to use all 5 filters accessible to those who use CloudFlare for free!

Cloudflare-Web Performance-Security

Happy blogging!

byrev Written by:

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *