Skip to content

Commit f473556

Browse files
committed
Update example (API, dashboard)
1 parent c92b871 commit f473556

File tree

4 files changed

+71
-131
lines changed

4 files changed

+71
-131
lines changed

src/content/docs/rules/origin-rules/create-api.mdx

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ Make sure your API token has the [required permissions](#required-api-token-perm
2929

3030
## Example requests
3131

32-
<Details header="Example: Add a rule that overrides the HTTP `Host` header and the resolved DNS record">
32+
<Details header="Example: Add a rule that overrides the `Host` header of incoming requests and the resolved DNS record">
3333

34-
<Render file="origin-rules-api-change-host-header" />
34+
<Render file="origin-rules-api-change-host-header-dns-record" />
3535

3636
</Details>
3737

@@ -66,66 +66,6 @@ The following example sets the rules of an existing phase ruleset (`$RULESET_ID`
6666

6767
</Details>
6868

69-
<Details header="Example: Add a rule that overrides the resolved DNS record and the `Host` header of incoming requests">
70-
71-
The following example sets the rules of an existing phase ruleset (`$RULESET_ID`) to a single origin rule — overriding the resolved DNS record and the `Host` header of incoming requests — using the [Update a zone ruleset](/api/resources/rulesets/methods/update/) operation. The response will contain the complete definition of the ruleset you updated.
72-
73-
<APIRequest
74-
path="/zones/{zone_id}/rulesets/{ruleset_id}"
75-
method="PUT"
76-
json={{
77-
rules: [
78-
{
79-
expression: 'starts_with(http.request.uri.path, "/hr-app/")',
80-
description: "Origin rule for the company HR application",
81-
action: "route",
82-
action_parameters: {
83-
host_header: "hr-server.example.com",
84-
origin: {
85-
host: "hr-server.example.com",
86-
},
87-
},
88-
},
89-
],
90-
}}
91-
/>
92-
93-
```json output
94-
{
95-
"result": {
96-
"id": "<RULESET_ID>",
97-
"name": "Origin Rules ruleset",
98-
"description": "Zone-level ruleset that will execute origin rules.",
99-
"kind": "zone",
100-
"version": "2",
101-
"rules": [
102-
{
103-
"id": "<RULE_ID>",
104-
"version": "1",
105-
"action": "route",
106-
"action_parameters": {
107-
"host_header": "hr-server.example.com",
108-
"origin": {
109-
"host": "hr-server.example.com"
110-
}
111-
},
112-
"expression": "starts_with(http.request.uri.path, \"/hr-app/\")",
113-
"description": "Origin rule for the company HR application",
114-
"last_updated": "2022-06-03T14:42:04.219025Z",
115-
"ref": "<RULE_REF>"
116-
}
117-
],
118-
"last_updated": "2022-06-03T14:42:04.219025Z",
119-
"phase": "http_request_origin"
120-
},
121-
"success": true,
122-
"errors": [],
123-
"messages": []
124-
}
125-
```
126-
127-
</Details>
128-
12969
---
13070

13171
## Required API token permissions

src/content/docs/rules/origin-rules/examples/change-http-host-header.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description: Create an origin rule to change the HTTP `Host` header and the reso
99

1010
import { Render, Tabs, TabItem, Example } from "~/components";
1111

12-
The following origin rule overrides the HTTP `Host` header to `eu_server.example.net` for all requests containing `/eu/` in their URI path. It also overrides the DNS record to the same hostname.
12+
The following origin rule overrides the HTTP `Host` header to `hr-server.example.com` for all requests with a URI path starting with `/hr-app/`. It also overrides the DNS record to the same hostname.
1313

1414
The `Host` header override only updates the header value; the DNS record override will handle the rerouting of incoming requests.
1515

@@ -20,34 +20,34 @@ The `Host` header override only updates the header value; the DNS record overrid
2020

2121
Expression when using the Expression Builder:
2222

23-
| Field | Operator | Value |
24-
| -------- | -------- | ------ |
25-
| URI Path | contains | `/eu/` |
23+
| Field | Operator | Value |
24+
| -------- | ----------- | ---------- |
25+
| URI Path | starts with | `/hr-app/` |
2626

2727
Expression when using the Expression Editor:
2828

2929
```txt
30-
(http.request.uri.path contains "/eu/")
30+
(starts_with(http.request.uri.path, "/hr-app/"))
3131
```
3232

3333
Value after **Host Header** > **Rewrite to**:
3434

3535
```txt
36-
eu_server.example.net
36+
hr-server.example.com
3737
```
3838

3939
Value after **DNS Record** > **Override to**:
4040

4141
```txt
42-
eu_server.example.net
42+
hr-server.example.com
4343
```
4444

4545
</Example>
4646

4747
</TabItem>
4848
<TabItem label="API" no-code="true">
4949

50-
<Render file="origin-rules-api-change-host-header" />
50+
<Render file="origin-rules-api-change-host-header-dns-record" />
5151

5252
</TabItem>
5353
</Tabs>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
{}
3+
---
4+
5+
import { APIRequest } from "~/components";
6+
7+
The following example sets the rules of an existing phase ruleset (`$RULESET_ID`) to a single origin rule — overriding the `Host` header of incoming requests and the resolved DNS — using the [Update a zone ruleset](/api/resources/rulesets/methods/update/) operation. The response will contain the complete definition of the ruleset you updated.
8+
9+
<APIRequest
10+
path="/zones/{zone_id}/rulesets/{ruleset_id}"
11+
method="PUT"
12+
json={{
13+
rules: [
14+
{
15+
expression: 'starts_with(http.request.uri.path, "/hr-app/")',
16+
description: "Origin rule for the company HR application",
17+
action: "route",
18+
action_parameters: {
19+
host_header: "hr-server.example.com",
20+
origin: {
21+
host: "hr-server.example.com",
22+
},
23+
},
24+
},
25+
],
26+
}}
27+
/>
28+
29+
```json output
30+
{
31+
"result": {
32+
"id": "<RULESET_ID>",
33+
"name": "Origin Rules ruleset",
34+
"description": "Zone-level ruleset that will execute origin rules.",
35+
"kind": "zone",
36+
"version": "2",
37+
"rules": [
38+
{
39+
"id": "<RULE_ID>",
40+
"version": "1",
41+
"action": "route",
42+
"action_parameters": {
43+
"host_header": "hr-server.example.com",
44+
"origin": {
45+
"host": "hr-server.example.com"
46+
}
47+
},
48+
"expression": "starts_with(http.request.uri.path, \"/hr-app/\")",
49+
"description": "Origin rule for the company HR application",
50+
"last_updated": "2022-06-03T14:42:04.219025Z",
51+
"ref": "<RULE_REF>"
52+
}
53+
],
54+
"last_updated": "2022-06-03T14:42:04.219025Z",
55+
"phase": "http_request_origin"
56+
},
57+
"success": true,
58+
"errors": [],
59+
"messages": []
60+
}
61+
```

src/content/partials/rules/origin-rules-api-change-host-header.mdx

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)