Knowledge Base
MilesWeb / Domain Name & DNS Issues

DDoS Protection using CloudFlare

Approx. read time : 2 min

The article describes how you can use CloudFlare to defend the website against DDoS (distributed denial-of-service) attacks.

What is DDoS Protection by Cloudflare?

DDoS attacks are becoming very common. In such type of attacks, multiple computers flood a target site with so much network traffic that it responds very slowly or not at all.

Related: What is CloudFlare Railgun and How to Enable it on Your Website?

Cloudflare’s distributed and redundant network helps to minimize the traffic associated with DDoS attacks. Additional to DDoS protection, Cloudflare also provides additional protections that you can enable such as “I’m under attack” mode. This is a security action that you can easily enable when your site is under the active attack. When it is enabled, the mode adds additional protection to stop potentially malicious HTTP traffic from reaching your site. Authorized visitor’s will see the followings page for about 5-6 seconds when the Cloudflare runs the check browser :

Check CloudFlare

Once Cloudflare completes the checking process, your site gets loaded normally.

To add an additional protection layer to your website, along with “I’m under attack” mode, you can also whitelist specific IP addresses.

# Steps to enable “I’m under attack” mode in Cloudflare

1. Log in to cPanel account.

2. Locate SOFTWARE section on the cPanel home screen, and click on Cloudflare.

3. Click on Enable “I’m Under Attack” Mode:

DDoS Protection 2

4. If you want to disable it, then click on Disable “I’m Under Attack” Mode:

DDoS Protection 3

# Steps to Whitelist IP address :

To protect your site from the malicious IP addresses, you can grant access to only specific IP addresses that you trust. This process is known as “whitelisting”, that provides an extra protection layer to your site.

Perform the following steps to do so :

1. By 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 will represent your account username.

2. Copy and paste the following text into the htaccess file :

order deny, allow
deny from all

3. Go to https://www.cloudflare.com/ips-v4. Copy and paste the entire list of IP addresses into the .htaccess file immediately after the deny from all line. Make sure that each IP address should be on a separate line.

4. Now add the following command at the start of each line that contains an IP address :

allow from

5. Use the allow from IP_address format to add the additional IP address (like your office or home IP address) to the whitelist.

6. You will now have the .htaccess file that will contain 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 the changes to the .htaccess file. Whitelisting will now be enabled.

That’s it!

Also Read :

1) Droplet gets Compromised and Sends an Outgoing Flood or DDoS – What to do?

With an interest in doing something creative daily, Sonam works as a Digital Marketing Executive. She likes to write technical blogs related to web hosting, digital marketing, and other IT topics. She also likes to spend her leisure time on social media to find different strategies for client engagement.

Trusted By Thousands of Clients & Big Businesses

We highly appreciate the kind and stellar feedback we receive from our customers. Delivering the best is our goal! MilesWeb is rated Excellent out of 5 based on reviews. Read more reviews.

Excellent
Based on reviews
2 hours ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
4 hours ago
Milesweb is superb Hosting pro...
Milesweb is superb Hosting provider ever, their Support team is amazing!!!...
Abhishek Singh
15 hours ago
Great support in great timing...
We need urgent assistance on changes in a primary domain on our client's Cpanel accounts and reached...
Riyaju Deen
21 hours ago
Best Website Hosting platform ...
I was new on MilesWeb. And needed help on multiple areas from setting up to getting started with cre...
Harshada
1 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
1 days ago
the team is very supportive th...
the team is very supportive though at times effort needs to be made to make understand the problem s...
Suree Sharma
1 days ago
I am using miles web for 3plus...
I am using miles web for 3plus years, very quick and perfect support by the team, they helped me man...
Sri Raghav
2 days ago
The service is good...
The service is good. They are answering with patience and doing the needful as soon as possible....
MR
2 days ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
3 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
4 days ago
positively helped me with find...
positively helped me with finding insecure content on my website causing SSL to not work properly on...
Thaviraj Junglee
4 days ago
Exceptional support, Truly Pra...
I had opted for the basic wordpress hosting plan as I intended to experiment with various plug-ins. ...
Aseem Chandna