Web Hosting Knowledge Base Web Hosting Knowledge Base
  • Home
Get Started
Web Hosting Knowledge Base Web Hosting Knowledge Base
Get Started
Web Hosting Knowledge Base Web Hosting Knowledge Base
  • Home
loading
  1. Home
  2. Add on Services
  3. How to use Cloudflare to defend against DDoS attacks
Updated on June 21, 2024

Add on Services

  • Folder icon closed Folder open iconHow to back up your data using Dropmysite
  • Folder icon closed Folder open iconHow to monitor blacklisted sites using Dropmysite
  • Folder icon closed Folder open iconHow to maximize Dropmysite backup storage space
  • Folder icon closed Folder open iconHow to restore your data using Dropmysite
  • Folder icon closed Folder open iconWhat is the Cloudflare CDN?
  • Folder icon closed Folder open iconHow to activate Cloudflare
  • Folder icon closed Folder open iconUsing SSL with Cloudflare
  • Folder icon closed Folder open iconTroubleshooting Cloudflare connections
  • Folder icon closed Folder open iconHow to use Cloudflare to defend against DDoS attacks
  • Folder icon closed Folder open iconSetting up Let's Encrypt and Cloudflare Universal SSL for end-to-end encryption
  • Folder icon closed Folder open iconHow to turn off Cloudflare temporarily for maintenance or development
  • Folder icon closed Folder open iconSetting up cPanel SSL and Cloudflare Universal SSL for end-to-end encryption
  • Folder icon closed Folder open iconHow to troubleshoot SSL certificate renewals for Cloudflare-enabled domains
  • Folder icon closed Folder open iconHow to clear the Cloudflare cache
  • Folder icon closed Folder open iconDiscontinuation of Cloudflare CDN cPanel and Plesk plugins
  • Folder icon closed Folder open iconHow to configure DNS records for email in Cloudflare
  • Folder icon closed Folder open iconRefer-a-friend program
  • Folder icon closed Folder open iconAffiliate program information
  • Folder icon closed Folder open iconHow to use the QUIC.cloud CDN with WordPress
  • Folder icon closed Folder open iconUsing Cloudflare
  • Folder icon closed Folder open iconSecure Sockets Layer (SSL) certificates information
  • Folder icon closed Folder open iconWHMCS hosting information
  • Folder icon closed Folder open iconHow to become a domain and SSL reseller with eNom
  • Folder icon closed Folder open iconHow to activate an SSL certificate as an eNom reseller
  • Folder icon closed Folder open iconHostvento Hosting promotions
  • Folder icon closed Folder open iconHow to order a cPanel license
  • Folder icon closed Folder open iconHow to configure OpenSRS access for WHMCS
  • Folder icon closed Folder open iconHow to sign up for a MailChimp account
  • Folder icon closed Folder open iconDropmysite cPanel plugin
  • Folder icon closed Folder open iconHow to order a WHMCS license
  • Folder icon closed Folder open iconHow to order a Blesta license
  • Folder icon closed Folder open iconHow to reset the administrator password in WHMCS
  • Folder icon closed Folder open iconHow to remove a banned IP address in WHMCS
  • Folder icon closed Folder open iconQUIC.cloud

How to use Cloudflare to defend against DDoS attacks

Estimated reading: 4 minutes 247 views

This article describes how to use Cloudflare to help defend against DDoS (distributed denial-of-service) attacks on your web site.

For information about how to activate Cloudflare for your account, please see this article. For detailed information about how to configure Cloudflare settings, please see the Cloudflare documentation.Table of Contents

  • About DDoS protection by Cloudflare
  • Enabling “Under Attack” mode in Cloudflare
  • Whitelisting IP addresses
  • More Information

About DDoS protection by Cloudflare

DDoS (distributed denial-of-service) attacks are becoming more and more common. In this type of attack, multiple computers flood a target site with so much network traffic that it responds very slowly or not at all.

Cloudflare’s distributed, redundant network helps absorb the flood of traffic associated with DDoS attacks. In addition to this built-in DDoS protection, Cloudflare provides additional protections you can enable, such as “Under Attack” mode. This is a security level you enable when your site is under active attack. When enabled, this mode adds additional protections to stop potentially malicious HTTP traffic from reaching your site. Legitimate visitors see the following page for about five seconds while Cloudflare runs checks on the browser:

Cloudflare - Under Attack interstitial page

After Cloudflare completes its checks, your site loads normally.

In addition to enabling “Under Attack” mode, you can whitelist specific IP addresses to add an additional layer of defense to your web site. The following sections describe how to do both of these actions.

Enabling “Under Attack” mode in Cloudflare

To enable “Under Attack” mode in Cloudflare, follow these steps:

  1. Log in to Cloudflare with your Cloudflare account.
  2. In the left sidebar, click Websites, and then click your domain name (for example, example.com):Cloudflare - Select domain
  3. In the right sidebar, under Quick Actions, click the Under Attack Mode slider:
    Cloudflare - Under Attack Mode enabled
  4. To disable “Under Attack” mode, click the Unde
  5. r Attack Mode slider again, and then select a security level:
    Cloudflare - Under Attack Mode disabledHostvento Hosting recommends using the High level after an attack, which means Cloudflare challenges all visitors that have exhibited threatening behavior within the last 14 days. When the attack has lessened or stopped, you can reset the security level to a lower level.

Whitelisting IP addresses

In addition to enabling Cloudflare’s “Under Attack” mode, you can prevent malicious IP addresses from accessing your site, and grant access only to specific IP addresses that you trust. This process, also known as “whitelisting”, provides another layer of protection for your site.

To do this, follow these steps:

  1. Using the cPanel File Manager or the SSH command prompt, open the /home/username/public_html/.htaccess file in your preferred text editor, where username represents your account username.If the .htaccess file does not already exist, create it.
  2. Copy the following text and then paste it into the .htaccess file:order deny,allow deny from all
  3. Use your web browser to go to https://www.cloudflare.com/ips-v4. Copy the entire list of IP addresses, and then paste it into the .htaccess file right after the deny from all line. Each IP address should be on a separate line.
    Cloudflare periodically updates this list of IPv4 addresses for its network. You should whitelist all of these IP addresses to ensure continued Cloudflare functionality for your site.
  4. Add the following text to the start of each line that contains an IP address:
    allow from
  5. To add additional IP addresses (such as your home or office IP address) to the whitelist, use the same allow from IP_address format.
    If you do not know your own IP address, you can visit http://ipfinder.us.
  6. You should now have an .htaccess file that contains the following content:
    order deny,allow deny from all allow from 103.21.244.0/22 [Additional Cloudflare IP addresses to allow] [Any other IP addresses you want to allow] Save your changes to the .htaccess file. Whitelisting is now enabled.To undo whitelisting, comment out the previous statements in the .htaccess file by placing a # character in front of each line (or just delete the lines entirely).

Read more – How to install Jcow using Softaculous

Still stuck? How can we help?

How can we help?

Was this page helpful? Yes No

Share this Doc

How to use Cloudflare to defend against DDoS attacks

Or copy link

Clipboard Icon
CONTENTS
  • About DDoS protection by Cloudflare
  • Enabling “Under Attack” mode in Cloudflare
  • Whitelisting IP addresses
Leaf Illustration

© 2023 All Rights Reserved by Hostvento