Skip to content

Commit 31bfe12

Browse files
Fill in APIRequest throughout
1 parent c6bb38c commit 31bfe12

File tree

3 files changed

+92
-27
lines changed

3 files changed

+92
-27
lines changed

src/content/docs/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata.mdx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,22 @@ curl --request PATCH \
5252
```
5353

5454
<APIRequest
55-
path=""
56-
method=""
57-
json={{}}
55+
path="/zones/{zone_id}/custom_hostnames/{hostname_id}"
56+
method="PATCH"
57+
json={{
58+
"ssl": {
59+
"method": "http",
60+
"type": "dv"
61+
},
62+
"custom_metadata": {
63+
"customer_id": "12345",
64+
"redirect_to_https": true,
65+
"security_tag": "low"
66+
},
67+
}}
5868
/>
5969

60-
Changes to metadata will propagate across Cloudflares edge within 30 seconds.
70+
Changes to metadata will propagate across Cloudflare's edge within 30 seconds.
6171

6272
---
6373

@@ -109,7 +119,7 @@ lookup_json_string(cf.hostname.metadata, "security_tag") eq "low"
109119
- Define fallback behaviour in the non-presence of metadata
110120
- Define fallback behaviour if a key or value in the metadata are unknown
111121

112-
General guidance is to follow [Googles JSON Style guide](https://google.github.io/styleguide/jsoncstyleguide.xml) where appropriate.
122+
General guidance is to follow [Google's JSON Style guide](https://google.github.io/styleguide/jsoncstyleguide.xml) where appropriate.
113123

114124
---
115125

@@ -118,7 +128,7 @@ General guidance is to follow [Google’s JSON Style guide](https://google.githu
118128
There are some limitations to the metadata that can be provided to Cloudflare:
119129

120130
- It must be valid JSON.
121-
- Any origin resolution — for example, directing requests for a given hostname to a specific backend — must be provided as a hostname that exists within Cloudflares DNS (even for non-authoritative setups). Providing an IP address directly will cause requests to error.
131+
- Any origin resolution — for example, directing requests for a given hostname to a specific backend — must be provided as a hostname that exists within Cloudflare's DNS (even for non-authoritative setups). Providing an IP address directly will cause requests to error.
122132
- The total payload must not exceed 4 KB.
123133
- It requires a Cloudflare Worker that knows how to process the schema and trigger logic based on the contents.
124134
- Custom metadata cannot be set on custom hostnames that contain wildcards.

src/content/docs/cloudflare-for-platforms/cloudflare-for-saas/performance/early-hints-for-saas.mdx

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,23 @@ curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/custom_hostnames" \
4949
```
5050

5151
<APIRequest
52-
path=""
53-
method=""
54-
json={{}}
52+
path="/zones/{zone_id}/custom_hostnames"
53+
method="POST"
54+
json={{
55+
"hostname": "{hostname}",
56+
"ssl": {
57+
"method": "http",
58+
"type": "dv",
59+
"settings": {
60+
"http2": "on",
61+
"min_tls_version": "1.2",
62+
"tls_1_3": "on",
63+
"early_hints": "on"
64+
},
65+
"bundle_method": "ubiquitous",
66+
"wildcard": false
67+
},
68+
}}
5569
/>
5670

5771
4. For an existing custom hostname, locate the `id` of that hostname via a `GET` call:
@@ -63,9 +77,11 @@ curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/custom_hostnames?host
6377
```
6478

6579
<APIRequest
66-
path=""
67-
method=""
68-
json={{}}
80+
path="/zones/{zone_id}/custom_hostnames"
81+
method="GET"
82+
parameters={{
83+
hostname:{hostname}
84+
}}
6985
/>
7086

7187
5. Then make an API call such as the example below, specifying `"early_hints": "on"`:
@@ -91,9 +107,20 @@ curl --request PATCH \
91107
```
92108

93109
<APIRequest
94-
path=""
95-
method=""
96-
json={{}}
110+
path="/zones/{zone_id}/custom_hostnames/{custom_hostname_id}"
111+
method="PATCH"
112+
json={{
113+
"ssl": {
114+
"method": "http",
115+
"type": "dv",
116+
"settings": {
117+
"http2": "on", // Note: These settings will be set to default if not included when updating early hints
118+
"min_tls_version": "1.2",
119+
"tls_1_3": "on",
120+
"early_hints": "on"
121+
}
122+
},
123+
}}
97124
/>
98125

99126
Currently, all options within `settings` are required in order to prevent those options from being set to default. You can pull the current settings state prior to updating Early Hints by leveraging the output that returns the `id` for the hostname.

src/content/docs/cloudflare-for-platforms/cloudflare-for-saas/security/waf-for-saas/index.mdx

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,14 @@ curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/custom_hostnames" \
2929
```
3030

3131
<APIRequest
32-
path=""
33-
method=""
34-
json={{}}
32+
path="/zones/{zone_id}/custom_hostnames"
33+
method="POST"
34+
json={{
35+
"hostname": "<CUSTOM_HOSTNAME>",
36+
"ssl": {
37+
wildcard: false
38+
},
39+
}}
3540
/>
3641

3742
## 1. Associate custom metadata to a custom hostname
@@ -51,9 +56,8 @@ curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/custom_hostnames" \
5156
```
5257

5358
<APIRequest
54-
path=""
55-
method=""
56-
json={{}}
59+
path="/zones/{zone_id}/custom_hostnames"
60+
method="GET"
5761
/>
5862

5963
4. Plan your [custom metadata](/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/). It is fully customizable. In the example below, we have chosen the tag `"security_level"` to which we expect to assign three values (low, medium, and high).
@@ -81,9 +85,14 @@ curl --request PATCH \
8185
```
8286

8387
<APIRequest
84-
path=""
85-
method=""
86-
json={{}}
88+
path="/zones/{zone_id}/custom_hostnames/{custom_hostname_id}"
89+
method="PATCH"
90+
json={{
91+
"custom_metadata": {
92+
"customer_id": "12345",
93+
"security_level": "low"
94+
},
95+
}}
8796
/>
8897

8998
This assigns custom metadata to your custom hostname so that it has a security tag associated with its ID.
@@ -119,9 +128,28 @@ curl --request PUT \
119128
```
120129

121130
<APIRequest
122-
path=""
123-
method=""
124-
json={{}}
131+
path="/zones/{zone_id}/rulesets/phases/{ruleset_phase}/entrypoint"
132+
method="PUT"
133+
json={{
134+
"rules": [
135+
{
136+
"action": "block",
137+
"ratelimit": {
138+
"characteristics": [
139+
"cf.colo.id",
140+
"ip.src"
141+
],
142+
"period": 10,
143+
"requests_per_period": 2,
144+
"mitigation_timeout": 60
145+
},
146+
"expression": "lookup_json_string(cf.hostname.metadata, \"security_level\") eq \"low\" and http.request.uri contains \"login\""
147+
}
148+
]
149+
}}
150+
parameter={{
151+
ruleset_phase: "http_ratelimit"
152+
}}
125153
/>
126154

127155
To build rules through the dashboard:

0 commit comments

Comments
 (0)