Skip to content

Commit c92b871

Browse files
committed
[Rules] Update Origin Rules
1 parent 8297868 commit c92b871

File tree

5 files changed

+39
-15
lines changed

5 files changed

+39
-15
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ 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">
32+
<Details header="Example: Add a rule that overrides the HTTP `Host` header and the resolved DNS record">
3333

3434
<Render file="origin-rules-api-change-host-header" />
3535

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

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
---
22
pcx_content_type: example
3-
summary: Create an origin rule to change the HTTP `Host` header.
3+
summary: Create an origin rule to change the HTTP `Host` header and DNS record.
44
products:
55
- Origin Rules
6-
title: Change the HTTP Host header
7-
description: Create an origin rule to change the HTTP `Host` header.
6+
title: Change the HTTP Host header and DNS record
7+
description: Create an origin rule to change the HTTP `Host` header and the resolved DNS record.
88
---
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.
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.
13+
14+
The `Host` header override only updates the header value; the DNS record override will handle the rerouting of incoming requests.
1315

1416
<Tabs syncKey="dashPlusAPI">
1517
<TabItem label="Dashboard" no-code="true">
1618

1719
<Example>
1820

19-
Text in Expression Editor:
21+
Expression when using the Expression Builder:
22+
23+
| Field | Operator | Value |
24+
| -------- | -------- | ------ |
25+
| URI Path | contains | `/eu/` |
26+
27+
Expression when using the Expression Editor:
2028

2129
```txt
22-
http.request.uri.path contains "/eu/"
30+
(http.request.uri.path contains "/eu/")
2331
```
2432

2533
Value after **Host Header** > **Rewrite to**:
@@ -28,6 +36,12 @@ Value after **Host Header** > **Rewrite to**:
2836
eu_server.example.net
2937
```
3038

39+
Value after **DNS Record** > **Override to**:
40+
41+
```txt
42+
eu_server.example.net
43+
```
44+
3145
</Example>
3246

3347
</TabItem>

src/content/docs/rules/origin-rules/features.mdx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ A common use case for this functionality is when your content is hosted on a thi
2020

2121
:::note[Notes]
2222

23-
- An origin rule performing a Host header override will also update the Server Name Indication (SNI) value of the original request to the same value. To set an SNI value different from the Host header value, add an [SNI override](#server-name-indication-sni) in the same origin rule or create a separate origin rule for this purpose.
23+
- In most situations, when you rewrite the HTTP `Host` header you also need to configure a [DNS record override](#dns-record). The `Host` header override only updates the header value; the DNS record override will handle the rerouting of the request.
24+
25+
- An origin rule performing a `Host` header override will also update the Server Name Indication (SNI) value of the original request to the same value. To set an SNI value different from the `Host` header value, add an [SNI override](#server-name-indication-sni) in the same origin rule or create a separate origin rule for this purpose.
2426

2527
- If you have configured load balancing through Cloudflare and you wish to override the HTTP `Host` header per origin or for a given monitor, refer to [Override HTTP Host headers](/load-balancing/additional-options/override-http-host-headers/) in the Load Balancing documentation for more information.
2628

@@ -30,10 +32,9 @@ A common use case for this functionality is when your content is hosted on a thi
3032

3133
Allows you to override the Server Name Indication (SNI) [^1] value of a request. For more information, refer to [What is SNI (Server Name Indication)?](https://www.cloudflare.com/learning/ssl/what-is-sni/) in the Learning Center.
3234

33-
The new SNI value must be a valid hostname on the same Cloudflare account (possibly on a different zone).
34-
3535
:::note[Notes]
3636

37+
- The new SNI value must be a valid hostname on the same Cloudflare account (possibly on a different zone).
3738
- Currently, you can only use a static value when overriding SNI.
3839
- An SNI override will take precedence over [SNI rewrites of custom origins](/cloudflare-for-platforms/cloudflare-for-saas/start/advanced-settings/custom-origin/#sni-rewrites) when using Cloudflare for SaaS.
3940

@@ -47,9 +48,13 @@ Allows you to override the resolved hostname of incoming requests. This function
4748

4849
A common use case is when you are serving an application from the URI (for example, `mydomain.com/app`). In this case, the `app` may be hosted on a different server or by a third party. A DNS record override allows you to redirect requests to this endpoint to the server for that third-party application.
4950

50-
You must specify a valid hostname in a DNS record override that is a hostname on the same Cloudflare account (possibly on a different zone).
51+
:::note
52+
53+
- You must specify a valid hostname in a DNS record override that is a hostname on the same Cloudflare account (possibly on a different zone). You can [configure a DNS record](/dns/manage-dns-records/how-to/create-dns-records#create-dns-records) (a `CNAME`, `A`, or `AAAA` record) with a hostname pointing to a third-party hostname/IP address, either proxied by Cloudflare or not.
5154

52-
You can [configure a DNS record](/dns/manage-dns-records/how-to/create-dns-records#create-dns-records) (a `CNAME`, `A`, or `AAAA` record) with a hostname pointing to a third-party hostname/IP address, either proxied by Cloudflare or not.
55+
- In most situations, when you configure a DNS record override you also need to configure a [`Host` header override](#dns-record). The DNS record override handles the rerouting of the request; the `Host` header override updates the `Host` HTTP header value in the request. Defining a `Host` header override will also update the Server Name Indication (SNI) value of the original request to the same value. To set an SNI value different from the `Host` header value, add an [SNI override](#server-name-indication-sni) in the same origin rule or create a separate origin rule for this purpose.
56+
57+
:::
5358

5459
The following example DNS records configure a `resolve.example.com` hostname pointing to an external hostname and IP address using a `CNAME` record and an `A` record, respectively:
5560

src/content/docs/rules/origin-rules/parameters.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Create [different overrides](/rules/origin-rules/features/) by including differe
1717
| DNS record override / Destination port override | [`origin` object](#dns-record-override-and-destination-port-override-parameters) |
1818

1919
:::note
20-
2120
The same origin rule can have different types of overrides. Refer to [Configuring several overrides in the same rule](#configuring-several-overrides-in-the-same-rule) for a syntax example.
2221
:::
2322

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

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

55
import { APIRequest } from "~/components";
66

7-
The following example sets the rules of an existing phase ruleset (`$RULESET_ID`) to a single origin rule — overriding the HTTP `Host` header — using the [Update a zone ruleset](/api/resources/rulesets/methods/update/) operation. The response will contain the complete definition of the ruleset you updated.
7+
The following example sets the rules of an existing phase ruleset (`$RULESET_ID`) to a single origin rule — overriding the HTTP `Host` header and the resolved DNS record — using the [Update a zone ruleset](/api/resources/rulesets/methods/update/) operation. The response will contain the complete definition of the ruleset you updated.
88

99
<APIRequest
1010
path="/zones/{zone_id}/rulesets/{ruleset_id}"
@@ -17,6 +17,9 @@ The following example sets the rules of an existing phase ruleset (`$RULESET_ID`
1717
action: "route",
1818
action_parameters: {
1919
host_header: "eu_server.example.net",
20+
origin: {
21+
host: "eu_server.example.net",
22+
},
2023
},
2124
},
2225
],
@@ -37,7 +40,10 @@ The following example sets the rules of an existing phase ruleset (`$RULESET_ID`
3740
"version": "1",
3841
"action": "route",
3942
"action_parameters": {
40-
"host_header": "eu_server.example.net"
43+
"host_header": "eu_server.example.net",
44+
"origin": {
45+
"host": "eu_server.example.net"
46+
}
4147
},
4248
"expression": "http.request.uri.path contains \"/eu/\"",
4349
"description": "My first origin rule",

0 commit comments

Comments
 (0)