Skip to content

Commit e0ad3cd

Browse files
committed
Add HTTP API example
1 parent 4f9de6a commit e0ad3cd

File tree

3 files changed

+65
-5
lines changed

3 files changed

+65
-5
lines changed

src/content/partials/cloudflare-one/gateway/get-started/create-dns-policy.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ To create a new DNS policy:
3838
--header "X-Auth-Key: <API_KEY>" \
3939
--data '{
4040
"name": "Block security risks",
41-
"description": "Block all default Cloudflare security categories",
41+
"description": "Block all default Cloudflare DNS security categories",
4242
"precedence": 0,
4343
"enabled": true,
4444
"action": "block",
4545
"filters": [
4646
"dns"
4747
],
4848
"traffic": "any(dns.security_category[*] in {68 178 80 83 176 175 117 131 134 151 153})"
49+
"identity": "",
50+
"device_posture": ""
4951
}'
5052
```
5153

src/content/partials/cloudflare-one/gateway/get-started/create-http-policy.mdx

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
{}
33
---
44

5-
import { Render } from "~/components";
5+
import { Render, Tabs, TabItem } from "~/components";
66

77
To create a new HTTP policy:
88

9+
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
10+
911
1. In [Zero Trust](https://one.dash.cloudflare.com/), go to **Gateway** > **Firewall policies**.
1012
2. In the **HTTP** tab, select **Add a policy**.
1113
3. Name the policy.
1214
4. Under **Traffic**, build a logical expression that defines the traffic you want to allow or block.
13-
5. Choose an **Action** to take when traffic matches the logical expression. For example, if you have enabled TLS inspection, some applications that use [embedded certificates](/cloudflare-one/policies/gateway/http-policies/tls-decryption/#inspection-limitations) may not support HTTP inspection, such as some Google products. You can create a policy to bypass inspection for these applications:
15+
5. Choose an **Action** to take when traffic matches the logical expression. For example, if you have enabled TLS decryption, some applications that use [embedded certificates](/cloudflare-one/policies/gateway/http-policies/tls-decryption/#inspection-limitations) may not support HTTP inspection, such as some Google products. You can create a policy to bypass inspection for these applications:
1416

1517
<Render
1618
file="gateway/policies/do-not-inspect-applications"
@@ -26,4 +28,59 @@ To create a new HTTP policy:
2628

2729
6. Select **Create policy**.
2830

31+
</TabItem>
32+
33+
<TabItem label="API">
34+
35+
1. [Create an API token](/fundamentals/api/get-started/create-token/) with the following permissions:
36+
37+
| Type | Item | Permission |
38+
| ------- | ---------- | ---------- |
39+
| Account | Zero Trust | Edit |
40+
41+
2. (Optional) Configure your API environment variables to include your [account ID](/fundamentals/setup/find-account-and-zone-ids/), email address, and API token.
42+
3. Send a `POST` request to the [Create a Zero Trust Gateway rule](/api/operations/zero-trust-gateway-rules-create-zero-trust-gateway-rule) endpoint. For example, if you have enabled TLS decryption, some applications that use [embedded certificates](/cloudflare-one/policies/gateway/http-policies/tls-decryption/#inspection-limitations) may not support HTTP inspection, such as some Google products. You can create a policy to bypass inspection for these applications:
43+
44+
```bash title="curl API example"
45+
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/gateway/rules \
46+
--header "X-Auth-Email: <EMAIL>" \
47+
--header "X-Auth-Key: <API_KEY>" \
48+
--data '{
49+
"name": "Do not inspect applications",
50+
"description": "Bypass TLS decryption for unsupported applications",
51+
"precedence": 0,
52+
"enabled": true,
53+
"action": "off",
54+
"filters": [
55+
"http"
56+
],
57+
"traffic": "any(app.type.ids[*] in {16})",
58+
"identity": "",
59+
"device_posture": ""
60+
}'
61+
```
62+
63+
Cloudflare also recommends adding a policy to block [known threats](/cloudflare-one/policies/gateway/domain-categories/#security-categories) such as Command & Control, Botnet and Malware based on Cloudflare's threat intelligence:
64+
65+
```bash title="curl API example"
66+
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/gateway/rules \
67+
--header "X-Auth-Email: <EMAIL>" \
68+
--header "X-Auth-Key: <API_KEY>" \
69+
--data '{
70+
"name": "Block security categories",
71+
"description": "Block all default Cloudflare HTTP security categories",
72+
"precedence": 0,
73+
"enabled": true,
74+
"action": "block",
75+
"filters": [
76+
"http"
77+
],
78+
"traffic": "any(http.request.uri.security_category[*] in {68 178 80 83 176 175 117 131 134 151 153})",
79+
"identity": "",
80+
"device_posture": ""
81+
}'
82+
```
83+
84+
</TabItem> </Tabs>
85+
2986
For more information, refer to [HTTP policies](/cloudflare-one/policies/gateway/http-policies/).

src/content/partials/cloudflare-one/gateway/get-started/create-network-policy.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
import { Render, Tabs, TabItem } from "~/components";
66

7-
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
8-
97
To create a new network policy:
108

9+
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
10+
1111
1. In [Zero Trust](https://one.dash.cloudflare.com/), go to **Gateway** > **Firewall policies**.
1212
2. In the **Network** tab, select **Add a policy**.
1313
3. Name the policy.
@@ -46,6 +46,7 @@ To create a new network policy:
4646
"l4"
4747
],
4848
"traffic": "any(net.sni.domains[*] == \"internalapp.com\")",
49+
"identity": "",
4950
"device_posture": "not(any(device_posture.checks.passed[*] in {\"<LIST_UUID>\"}))"
5051
}'
5152
```

0 commit comments

Comments
 (0)