How to Copy & Paste Cloudflare Firewall Rules without Terraform (or anything else).

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!

  1. Login to Cloudflare account and pick the domain with source Firewall Rules already setup how you want them;
  2. Select Edit for the Firewall Rule you wish to copy;
  3. 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.
  4. Highlight all in the box (or hit CTRL-A) and Copy (CTRL-C) content.
  5. Select CANCEL for that rule.
  6. Pick other Cloudflare domain to target with new Firewall Rule;
  7. Add new Firewall Rule, then
  8. Edit Expression and Paste (or hit CTRL-V) content.
  9. 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.

Phil

Grown up in Cleveland, Ohio, USA., and recently co-located to Asheville, North Carolina area. Trained as Army MP, but bit of a renegade career wise. Phil has owned businesses in insurance, private investigations industries, and has experience in computer network engineering, asset recovery and repossession, and commercial over the road truck driving. Career long entrepreneur, property investor and rental manager. Phil loves sharing his experiences of great food, travel, experiences and products.