Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bobbyiliev/cloudflare-ddos-protection
You can use this CLI script to enable and disable the CloudFlare DDOS protection for your website automatically based on the CPU load of your server.
https://github.com/bobbyiliev/cloudflare-ddos-protection
bash cloudflare cloudflare-ddos-protection hacktoberfest
Last synced: 2 months ago
JSON representation
You can use this CLI script to enable and disable the CloudFlare DDOS protection for your website automatically based on the CPU load of your server.
- Host: GitHub
- URL: https://github.com/bobbyiliev/cloudflare-ddos-protection
- Owner: bobbyiliev
- Created: 2020-06-18T13:38:39.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-24T10:15:01.000Z (almost 2 years ago)
- Last Synced: 2024-10-14T08:17:08.381Z (3 months ago)
- Topics: bash, cloudflare, cloudflare-ddos-protection, hacktoberfest
- Language: Shell
- Homepage: https://ebook.bobby.sh
- Size: 10.7 KB
- Stars: 24
- Watchers: 7
- Forks: 17
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cloudflare DDoS Protection Script
Cloudflare offers free DDoS protection and they have a cool API that you could use to enable and disable their DDoS protection easily.
You can use this CLI script to enable and disable the CloudFlare DDOS protection for your website automatically based on the CPU load of your server.
## Prerequisites
* A Cloudflare account
* Cloudflare API key
* Cloudflare Zone ID
* Make sure curl is installed on your server: `curl --version`If curl is not installed you need to run the following:
For RedHat/CentOs:
```
yum install curl
```
For Debian/Ubuntu```
apt-get install curl
```## Setup
All you need to do is to download the script and save it on your server.
Make the script executable:
```
chmod +x ~/protection.sh
```Update the Cloudflare API key and Zone ID in the script.
Setup 2 Cron jobs to run every 30 seconds. To edit your crontab run:
```
crontab -e
```And add the following content:
```
* * * * * /path-to-the-script/cloudflare/protection.sh
* * * * * ( sleep 30 ; /path-to-the-script/cloudflare/protection.sh )
```For more information check out the [Cloudflare API docs](https://developers.cloudflare.com/api/operations/zone-settings-change-security-level-setting).