Deploy a managed ruleset with ruleset, category, and rule overrides
Customize the deployment of managed rulesets with a combination of ruleset overrides, category overrides, and rule overrides in your root ruleset.
- Create a root ruleset if you do not already have one.
- Add a rule to your root ruleset to deploy a managed ruleset.
- Configure a ruleset override that disables all rules in the managed ruleset.
- Configure a category override that sets an action for rules tagged with a category.
- Configure a rule override that sets an action for the rules you want to deploy.
The request below uses the modify ruleset operation to execute the following in a single PUT request:
- Add a rule to the root ruleset that applies the Cloudflare Managed Ruleset to requests for example.com.
- Use category overrides to enable rules in the WordPress and Drupal categories and set their actions to
log
. - Add a rule override that enables a single rule.
curl -s -X PUT "https://api.cloudflare.com/client/v4/accounts/{account-id}/rulesets/{root-ruleset-id}" --data '{ "description": "My Root ruleset with ruleset, category and rule overrides", "rules": [ { "action": "execute", "expression": "cf.zone.name eq \"example.com\"", "action_parameters": { "id": "{managed_Ruleset_id}", "overrides": { "rulesets": [ { "enabled": "false" }], "categories": [ { "category": "wordpress", "action": "log" }, { "category": "drupal", "action": "log" }], "rules": [ { "id": "{rule-id}", "action": "block" }] } } }]}'
"ruleset": {"id": "{managed_ruleset_id}"}
adds a rule to the root ruleset that applies the Cloudflare Managed Ruleset to requests forexample.com
."overrides": {"rulesets": {"enabled": false}}
defines an override at the ruleset level to disable all rules in the managed ruleset."overrides": {"category": wordpress", "action": "log"}
defines an override at the category level to enable rules tagged withwordpress
and sets their action tolog
."overrides": {"rules": [{"id": "{rule-id}", "action": "block"}]}
defines an override at the rule level that enables one individual rule and sets the action toblock
.