Check your current rules first (sudo ufw status numbered); if you're
already allowing traffic to ports 80 and 443 from anywhere, delete
those rules with sudo ufw rule delete X (replace X with appropriate
rule number).
Make sure you're allowing SSH traffic for yourself before enabling!
sudo ufw allow ssh to be "safe" — restrict SSH to your own IPs
later if you'd like to actually be safe. ;)
Run this script once and then sudo ufw enable to lock everything down.
To run as a daily cron job:
sudo crontab -e- Add this line to the end:
@daily /file/location/cloudflare-ufw.sh &> /dev/null
Thanks for great work. I had a little problem "ERROR: Bad source address", which caused the last address not to be added. To fix it just add
echo "\n" >> /tmp/cf_ipsafter firstcurlline.