How to Stop Comment Spam in WordPress Using Cloudflare WAF Rule with JS Challenge

  • Post last modified:October 21, 2023
  • Post category:Web
  • Post comments:0 Comments
  • Reading time:3 mins read

Comment spam is a common thing that can affect WordPress websites. In this post, I will show you detailed steps on how to use a custom WAF rule with JS Challenge in Cloudflare to block comment spam in WordPress.


Table of Contents:

Step 1: Create a Custom WAF Rule

Log in to your Cloudflare Account, go to the “Security” tab and select the “WAF” tab and click on “Custom Rules“. Here, you can create a new custom WAF rule by clicking on the “Create Rule” button. In the rule creation screen, set the “Field” to “URL“, the “Operator” to “contains“, and the “Value” to “wp-comments-post.php“, which is the WordPress file that handles comment submissions.

Step 2: Enable JS Challenge

In the “Actions” section of the custom WAF rule, select “JS Challenge” from the drop-down menu, and then click on the “Deploy” button to enable the JS Challenge for this rule.

Adding WAF rule using Cloudflare Dashboard



By creating a custom WAF rule with JS Challenge using Cloudflare, you can block spam comments. By following the steps outlined in this post, you can keep your comment section clean and spam-free.

Leave a Reply