Skip to main content

Adding Security Rules in Cloudflare

Updated over a month ago

This guide will describe how to configure your Cloudflare security rules. You will first need to sign into your Cloudflare account, navigate to the Security page on the left, then select Security Rules. Here you will create the new Security Rules.

  1. Set the title of the first rule to: “Allow BetterStack and StatusCake and LetsEncrypt”

    1. Copy and paste this into the expression field: (http.user_agent contains "BetterStackStack") or (http.user_agent contains "StatusCake") or (http.request.uri contains "/.well-known/acme-challenge/") or (http.user_agent contains "Ads") or (cf.client.bot) or (cf.verified_bot_category eq "Advertising & Marketing") or (ip.src.asnum eq 15169)

    2. Set the action to: Skip

    3. Assign the following WAF components to skip:

      1. All remaining custom rules

      2. All rate limiting rules

      3. All managed rules

      4. All Super Bot Fight Mode Rules

2. Set the title of the second rule to: “High security for contact-us”

  1. Copy and paste this into the expression field: http.request.uri.path contains "contact-us"

  2. Set the action to: Managed Challenge

  3. Place at last (we will set the next rule to last, after that we will come back to this rule and place it after the first rule)

3. Set the title of the third rule to: “Block all outside US and Canada except BOT”

  1. Copy and paste this into the expression field: (ip.geoip.country ne "US" and ip.geoip.country ne "CA") and not cf.client.bot

  2. Set the action to: Block

  3. Place at last

Did this answer your question?