Enhancing Website Security with Cloudflare: A How-To Guide

Tomer Klein
4 min readNov 2, 2023

Introduction

In the digital age, website security is of paramount importance. Cloudflare, a widely-used content delivery and security provider, offers a range of tools to protect your online assets. One key feature is its robust security capabilities, including Web Application Firewall (WAF) and Geo-blocking, which help prevent unwanted access and mitigate various types of attacks. In this step-by-step guide, we will walk you through the process of leveraging Cloudflare to enhance your website’s security. Whether you’re a beginner or an experienced user, you’ll find this guide easy to follow, so let’s get started.

Step 1: Configure Web Application Firewall (WAF) and Geo-blocking

Cloudflare provides essential security features that can help safeguard your web resources. This step focuses on configuring WAF and Geo-blocking to enhance your website’s security.

Step 1.1: Accessing WAF Configuration

To start, log in to your Cloudflare account and select the domain for which you want to configure security settings. Navigate to the “Security” menu and click on “WAF.”

Now, on the menu click on “Security” and then on “WAF”:

Step 1.2: Setting Up Custom Rules

In the WAF settings, you will find various options. We will concentrate on creating custom rules to block access based on geographic locations.

Click on “Create Rule” to create your first rule. In this example, we’ll set up a rule to block access from Israel. Follow these parameters:

  • Rule Name: Provide a meaningful name, such as “Block Access from Israel.”
  • Field: Specify the parameter (e.g., country) for the rule.
  • Operator: Choose the appropriate operator for your rule (e.g., “=” for blocking a specific country).
  • Value: Enter the value associated with the operator (e.g., “Israel”).
  • Choose Action: Select “Block” as the action to take when the rule is triggered.

After configuring the rule, click “Deploy” to activate it.
If you try to access your website or application you will be blocked and see the following message:

Step 2: Monitor and Analyze Security Events

Under the “Security” section, you can keep track of all events and actions, including blocked accesses and other security-related activities.

Step 3: Enable Bot Fight Mode

Another highly recommended security measure is protection against bots. From my personal experience, I have encountered situations where my home network and websites were subjected to bot attacks. Thankfully, Cloudflare offers a built-in security mechanism called “Bot Fight Mode.” Enabling this feature is as simple as activating Geo-based blocking and can be done within the Security section. All you need to do is access the Security menu and enable “Bot Fight Mode.” This additional layer of defense will help safeguard your website and online assets from malicious bot activity.

Go to the “Security” menu and enable “Bot Fight Mode.”

Summary

In this how-to guide, we’ve explored how to enhance your website’s security using Cloudflare’s security features, such as Web Application Firewall (WAF) and Geo-blocking. By following the step-by-step instructions, you can configure custom rules to block unwanted traffic based on geographic locations. Additionally, we discussed the significance of Bot Fight Mode in protecting your website from malicious bots. With Cloudflare’s powerful security tools at your disposal, you can ensure a safer online experience for your users. Stay secure, and enjoy the peace of mind that comes with robust web protection.

--

--

Tomer Klein

🚀 C#/Python Developer crafting IoT magic, fueled by open source passion. Smart homes whisperer, code contributor, and tech explorer. 🌟