|
1 | 1 | --- |
2 | 2 | pcx_content_type: how-to |
3 | | -title: Managed Rulesets |
| 3 | +title: Managed rulesets |
4 | 4 | sidebar: |
5 | 5 | order: 4 |
6 | 6 | head: |
7 | 7 | - tag: title |
8 | | - content: Managed Rulesets per Custom Hostname |
9 | | - |
| 8 | + content: Managed rulesets per custom hostname |
10 | 9 | --- |
11 | 10 |
|
12 | 11 | import { DashButton } from "~/components"; |
13 | 12 |
|
14 | 13 | If you are interested in [WAF for SaaS](/cloudflare-for-platforms/cloudflare-for-saas/security/waf-for-saas/) but unsure of where to start, Cloudflare recommends using WAF Managed Rules. The Cloudflare security team creates and manages a variety of rules designed to detect common attack vectors and protect applications from vulnerabilities. These rules are offered in [managed rulesets](/waf/managed-rules/), like Cloudflare Managed and OWASP, which can be deployed with different settings and sensitivity levels. |
15 | 14 |
|
16 | | -*** |
| 15 | +--- |
17 | 16 |
|
18 | 17 | ## Prerequisites |
19 | 18 |
|
20 | 19 | WAF for SaaS is available for customers on an Enterprise plan. |
21 | 20 |
|
22 | | -If you would like to deploy a managed ruleset at the account level, refer to the [Ruleset Engine documentation](/ruleset-engine/managed-rulesets/deploy-managed-ruleset/). |
| 21 | +If you would like to deploy a managed ruleset at the account level, refer to the [WAF documentation](/waf/account/managed-rulesets/deploy-dashboard/). |
23 | 22 |
|
24 | 23 | Ensure you have reviewed [Get Started with Cloudflare for SaaS](/cloudflare-for-platforms/cloudflare-for-saas/start/getting-started/) and familiarize yourself with [WAF for SaaS](/cloudflare-for-platforms/cloudflare-for-saas/security/waf-for-saas/). |
25 | 24 |
|
26 | 25 | Customers can automate the [custom metadata](/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/) tagging by adding it to the custom hostnames at creation. For more information on tagging a custom hostname with custom metadata, refer to the [API documentation](/api/resources/custom_hostnames/methods/edit/). |
27 | 26 |
|
28 | | -*** |
| 27 | +--- |
29 | 28 |
|
30 | 29 | ## 1. Choose security tagging system |
31 | 30 |
|
32 | 31 | 1. Outline `security_tag` buckets. These are fully customizable with no strict limit on quantity. For example, you can set `security_tag` to `low`,`medium`, and `high` as a default, with one tag per custom hostname. |
33 | 32 |
|
34 | 33 | 2. If you have not already done so, [associate your custom metadata to custom hostnames](/cloudflare-for-platforms/cloudflare-for-saas/security/waf-for-saas/#1-associate-custom-metadata-to-a-custom-hostname) by including the `security_tag`in the custom metadata associated with the custom hostname. The JSON blob associated with the custom hostname is fully customizable. |
35 | 34 |
|
36 | | -:::note |
37 | | - |
| 35 | +After the association is complete, the JSON blob is added to the defined custom hostname. This blob is then associated to every incoming request and exposed in the WAF through the [`cf.hostname.metadata`](/ruleset-engine/rules-language/fields/reference/cf.hostname.metadata/) field. In the rule, you can access `cf.hostname.metadata` and get whatever data you need from that blob. |
38 | 36 |
|
39 | | -After the association is complete, the JSON blob is added to the defined custom hostname. This blob is then associated to every incoming request and exposed in the WAF through the new field `cf.hostname.metadata`. In the rule, you can access `cf.hostname.metadata` and get whatever data you need from that blob. |
| 37 | +--- |
40 | 38 |
|
| 39 | +## 2. Deploy rulesets |
41 | 40 |
|
| 41 | +:::note |
| 42 | +Account-level WAF requires an Enterprise plan with a paid add-on. |
42 | 43 | ::: |
43 | 44 |
|
44 | | -*** |
45 | | - |
46 | | -## 2. Deploy Rulesets |
47 | | - |
48 | 45 | 1. In the Cloudflare dashboard, go to the **WAF** page. |
49 | 46 |
|
50 | 47 | <DashButton url="/?to=/:account/application-security/waf" /> |
51 | 48 |
|
52 | | -:::note |
53 | | -**WAF** at the account level will only be visible on Enterprise plans. If you do not see this option, contact your account manager. |
54 | | -::: |
| 49 | +2. Go to the **Managed rulesets** tab. |
55 | 50 |
|
56 | | -2. Select **Managed rulesets**. |
| 51 | +3. Select **Deploy** > **Deploy managed ruleset**. |
57 | 52 |
|
58 | | -3. Select **Deploy a managed ruleset**. |
| 53 | +4. Next to **Cloudflare Managed Ruleset**, choose **Select ruleset**. |
59 | 54 |
|
60 | | -4. Under **Field**, Select *Hostname*. Set the operator as *equals*. The complete expression should look like this, plus any logic you would like to add: |
| 55 | +5. Give a name to the rule deploying the ruleset in **Execution name**. |
61 | 56 |
|
62 | | - |
| 57 | +6. Select **Edit scope** to execute the managed ruleset for a subset of incoming requests. |
63 | 58 |
|
64 | | -5. Beneath **Value**, add the custom hostname. |
| 59 | +7. Select **Custom filter expression**. |
65 | 60 |
|
66 | | -6. Select **Next**. |
| 61 | +8. Select **Edit expression** to switch to the [Expression Editor](/ruleset-engine/rules-language/expressions/edit-expressions/#expression-editor). |
67 | 62 |
|
68 | | -7. Find the **Cloudflare Managed Ruleset** card and select **Use this Ruleset**. |
| 63 | +9. The basic expression should look like this, plus any logic you would like to add (like filtering by a specific custom hostname with `http.host eq "<HOSTNAME>"`): |
69 | 64 |
|
70 | | -8. Click the checkbox next to each rule you want to deploy. |
| 65 | + ```txt |
| 66 | + (lookup_json_string(cf.hostname.metadata, "security_tag") eq "low") and (cf.zone.plan eq "ENT") |
| 67 | + ``` |
71 | 68 |
|
72 | | -9. Toggle the **Status** button next to each rule to enable or disable it. Then select **Next**. |
| 69 | + :::note |
| 70 | + Rulesets deployed at the account level will only apply to incoming traffic of Enterprise domains on your account. When you define a custom expression using the Expression Editor, use parentheses to enclose any custom conditions and end your expression with `and (cf.zone.plan eq "ENT")` so that the rule only applies to domains on an Enterprise plan. |
| 71 | + ::: |
73 | 72 |
|
74 | | -10. On the review page, give your rule a descriptive name. You can modify the ruleset configuration by changing, for example, what rules are enabled or what action should be the default. |
| 73 | +10. Select **Next**. |
75 | 74 |
|
76 | | -11. Select **Deploy**. |
| 75 | +11. (Optional) You can modify the ruleset configuration by changing, for example, what rules are enabled or what action should be the default. |
77 | 76 |
|
78 | | -:::note |
| 77 | +12. Select **Deploy**. |
79 | 78 |
|
| 79 | +## Next steps |
80 | 80 |
|
81 | | -While this tutorial uses Cloudflare Managed Rulesets, you can also create a custom ruleset and deploy on your custom hostnames. To do this, select **Browse Rulesets** > **Create new ruleset**. For examples of a low/medium/high ruleset, refer to [WAF for SaaS](/cloudflare-for-platforms/cloudflare-for-saas/security/waf-for-saas/). |
82 | | - |
83 | | - |
84 | | -::: |
| 81 | +While this guide uses the Cloudflare Managed Ruleset, you can also create a custom ruleset and deploy on your custom hostnames. To do this, go to the **Custom rulesets** tab and select **Create ruleset**. For examples of a low/medium/high ruleset, refer to [WAF for SaaS](/cloudflare-for-platforms/cloudflare-for-saas/security/waf-for-saas/). |
0 commit comments