A little script to update DigitalOcean firewalls with official CloudFlare IPs.
This is useful to protect your backends against direct DoS and DDoS attacks on ports 80 and 443.
All Inbound Rules with type = HTTP
or type = HTTPS
of each Firewall will be overwritten.
git clone https://github.com/offensive-hub/digitalocean-firewall.git
cd digitalocean-firewall
sudo apt-get install python-pip && sudo pip install -U -r requirements.txt
cp .env.example .env && chmod 600 .env
- Write right Digital Ocean Access Token in .env file
- Create an Inbound Rule with
type=HTTP
ortype=HTTPS
as following: - Execute
./update-firewalls.py
- Now you have two new Inbound Rules containing the official CloudFlare IPs:
It would be useful to make a cron, which update the firewalls every X time.
If you want that, follow these instructions:
crontab -e
- Paste the following code at the end of file:
# [00:00] Update DigitalOcean Firewalls with CloudFlare IPs 0 0 * * * /path/to/digitalocean-firewall/update-firewalls.py
- Edit
/path/to/
with your real path - Now your server will automatically update DigitalOcean Firewalls every day at midnight! :)