Copying rules to ~100 parked domains

I have about 100 domains parked on top of my main domain. I just now finished setting up the first site and created 1 Cache Rule (to prevent caching for certain URI Paths) and and 1 Origin Rule (to block non-US IPs).

It looks like I’ll have to create both rules for every site, though :open_mouth: Is that right? If so, I’d end up with 100 Cache Rules and 100 Origin Rules!

Since I’m working with parked domains, the rules would be identical for all of them. Is there a better way to manage the rules?

Use the API with a script to loop through the zones and add the rules. (edit: for page rules this is easy, the zone rulesets API is a little more involved)

1 Like

Note that I’m using the Free account, so I only have 10 Cache Rules and 10 Origin Rules. Will this make 100 of each; ie, exceeding the limit?

When you say “parked on top of my main domain” do you mean these are subdomains of a single zone?

In that case it’s easy, for the one zone you can just add one rule and apply to all requests. For cache rules use something that matches everything such as “hostname contains” (your main domain). For origin rules, select to apply to all traffic.

No, I mean that I have 100 domains and they are all parked on top of another domain. Then the code for that main domain reads the domain name and shows content appropriate to that parked domain.

So a user can go to 100 domains and think that they’re seeing 100 different sites, but it’s REALLY just one site.

Example, view and; two examples of the domains that are parked on top of

OK, so you have 100+ zones in Cloudflare?. In that case, yes, looping using the API is the way to set all the same. The limit on rules is per zone, so 1 origin rule and 1 cache rule per zone is ok.

Forgive me, but I don’t know what you mean by “Zones”.

I currently have one website in my account, and I figured that I’d need to set up 100 websites with identical rules and settings. Is that what you mean by “zones”?

I wish that there was a way to add parked domains without having to duplicate everything (and God forbid I need to change something in the future! LOL), but maybe one day :slight_smile:

Yes, a zone is a domain name in Cloudflare. I assumed they were all in Cloudflare already as you want to add cache and origin rules to them. You can’t handle those domains with Cloudflare rules if they aren’t in Cloudflare.

1 Like

Haha, that makes sense, of course :stuck_out_tongue: I just added one of my smaller sites last night so that I could test it out and get everything working right. So far so good, so my plan is to add all but my largest site tonight for further testing. Once all is well, I’ll add that final site manually (hopefully this weekend).

1 Like