After I got Cloudflare implemented on one domain, I was surprised there was no option to copy the firewall rules to other domains. Sure, there were plenty of great articles describing how to use Cloudflare firewall rules to protect my webapp, or using Cloudflare protect WordPress sites. Even some forum posts with others wondering how to duplicate Cloudflare firewall rules. But no solutions, short of using yet another layer – and third party app – called Terraform. I’m sure it’s a great tool, but way to complicated. I just wanted to copy and paste.
How to Copy and Paste Cloudflare Firewall Rules to Multiple Domains
Cloudflare allows us to do just that!
- Login to Cloudflare account and pick the domain with source Firewall Rules already setup how you want them;
- Select Edit for the Firewall Rule you wish to copy;
- Scroll down in the existing Firewall Rule, below all of the steps and above the CANCEL/SAVE buttons, you will find Expression Preview. Click Edit Expression.
- Highlight all in the box (or hit CTRL-A) and Copy (CTRL-C) content.
- Select CANCEL for that rule.
- Pick other Cloudflare domain to target with new Firewall Rule;
- Add new Firewall Rule, then
- Edit Expression and Paste (or hit CTRL-V) content.
- Select SAVE for that rule.
It’s a little cumbersome, you will need to repeat individually for each rule and domain. However, for complicated and multiple records and domains, it’s much easier than manually building each Cloudflare firewall rule individually.
I actually saved a text file with each firewall rule included, so I can copy/paste all the rules in one domain at one time.
Hope this helps someone, it’s better than nothing. And it’s free. LOL.