Skip to content

Commit 2a743a5

Browse files
committed
Update API examples for additional tools (UA blocking, zone lockdown)
1 parent 9441c2c commit 2a743a5

File tree

2 files changed

+44
-54
lines changed

2 files changed

+44
-54
lines changed

src/content/docs/waf/tools/user-agent-blocking.mdx

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ sidebar:
66
order: 3
77
---
88

9-
import { FeatureTable, TabItem, Tabs } from "~/components";
9+
import { FeatureTable, TabItem, Tabs, APIRequest } from "~/components";
1010

11-
User Agent Blocking rules block specific browser or web application [`User-Agent` request headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent). These rules apply to the entire domain instead of individual subdomains.
11+
User Agent Blocking rules block specific browser or web application [`User-Agent` request headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent). These rules apply to the entire domain instead of individual subdomains.
1212

13-
User Agent Blocking rules are applied after [Zone Lockdown rules](/waf/tools/zone-lockdown/). If you allow an IP address via Zone Lockdown, it will skip any User Agent Blocking rules.
13+
User Agent Blocking rules are applied after [Zone Lockdown rules](/waf/tools/zone-lockdown/). If you allow an IP address via Zone Lockdown, it will skip any User Agent Blocking rules.
1414

1515
:::caution
1616

@@ -43,30 +43,26 @@ Cloudflare User Agent Blocking is available on all plans. The number of availabl
4343

4444
5. In **Action**, select the action to perform: _Managed Challenge_, _Block_, _JS Challenge_, or _Interactive Challenge_.
4545

46-
6. Enter a user agent value in **User Agent** (wildcards such as `*` are not supported). For example, to block the Bad Bot web spider, enter `BadBot/1.0.2 (+http://bad.bot)`.
46+
6. Enter a user agent value in **User Agent** (wildcards such as `*` are not supported). For example, to block the Bad Bot web spider, enter `BadBot/1.0.2 (+http://bad.bot)`.
4747

4848
7. Select **Save and Deploy blocking rule**.
4949

5050
</TabItem> <TabItem label="API">
5151

52-
Issue a `POST` request for the [Create a User Agent Blocking rule](/api/resources/firewall/subresources/ua_rules/methods/create/) operation.
53-
54-
For example:
55-
56-
```bash
57-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/firewall/ua_rules" \
58-
--header "X-Auth-Email: <EMAIL>" \
59-
--header "X-Auth-Key: <API_KEY>" \
60-
--header "Content-Type: application/json" \
61-
--data '{
62-
"description": "Block Bad Bot web spider",
63-
"mode": "block",
64-
"configuration": {
65-
"target": "ua",
66-
"value": "BadBot/1.0.2 (+http://bad.bot)"
67-
}
68-
}'
69-
```
52+
Issue a `POST` request for the [Create a User Agent Blocking rule](/api/resources/firewall/subresources/ua_rules/methods/create/) operation similar to the following:
53+
54+
<APIRequest
55+
path="/zones/{zone_id}/firewall/ua_rules"
56+
method="POST"
57+
json={{
58+
description: "Block Bad Bot web spider",
59+
mode: "block",
60+
configuration: {
61+
target: "ua",
62+
value: "BadBot/1.0.2 (+http://bad.bot)",
63+
},
64+
}}
65+
/>
7066

7167
</TabItem> </Tabs>
7268

src/content/docs/waf/tools/zone-lockdown.mdx

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sidebar:
66
order: 4
77
---
88

9-
import { FeatureTable, TabItem, Tabs } from "~/components";
9+
import { FeatureTable, TabItem, Tabs, APIRequest } from "~/components";
1010

1111
Zone Lockdown specifies a list of one or more IP addresses, CIDR ranges, or networks that are the only IPs allowed to access a domain, subdomain, or URL. You can configure multiple destinations, including IPv4/IPv6 addresses, in a single Zone Lockdown rule.
1212

@@ -52,37 +52,31 @@ Cloudflare Zone Lockdown is available on paid plans. The number of available Zon
5252

5353
</TabItem> <TabItem label="API">
5454

55-
Issue a `POST` request for the [Create a Zone Lockdown rule](/api/resources/firewall/subresources/lockdowns/methods/create/) operation.
56-
57-
For example:
58-
59-
```bash
60-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/firewall/lockdowns" \
61-
--header "X-Auth-Email: <EMAIL>" \
62-
--header "X-Auth-Key: <API_KEY>" \
63-
--header "Content-Type: application/json" \
64-
--data '{
65-
"description": "Block all traffic to staging and wiki unless it comes from HQ or branch offices",
66-
"urls": [
67-
"staging.example.com/*",
68-
"example.com/wiki/*"
69-
],
70-
"configurations": [
71-
{
72-
"target": "ip_range",
73-
"value": "192.0.2.0/24"
74-
},
75-
{
76-
"target": "ip_range",
77-
"value": "2001:DB8::/64"
78-
},
79-
{
80-
"target": "ip",
81-
"value": "203.0.133.1"
82-
}
83-
]
84-
}'
85-
```
55+
Issue a `POST` request for the [Create a Zone Lockdown rule](/api/resources/firewall/subresources/lockdowns/methods/create/) operation similar to the following:
56+
57+
<APIRequest
58+
path="/zones/{zone_id}/firewall/lockdowns"
59+
method="POST"
60+
json={{
61+
description:
62+
"Block all traffic to staging and wiki unless it comes from HQ or branch offices",
63+
urls: ["staging.example.com/*", "example.com/wiki/*"],
64+
configurations: [
65+
{
66+
target: "ip_range",
67+
value: "192.0.2.0/24",
68+
},
69+
{
70+
target: "ip_range",
71+
value: "2001:DB8::/64",
72+
},
73+
{
74+
target: "ip",
75+
value: "203.0.133.1",
76+
},
77+
],
78+
}}
79+
/>
8680

8781
</TabItem> </Tabs>
8882

0 commit comments

Comments
 (0)