Skip to content

Commit 1c64aeb

Browse files
[BYOIP] CDN with Spectrum binding and clarify address maps (#22550)
* Review existing guide and prepare linkning to parent page * Add placeholder new page and link from service-bindings index * Add h2 to clarify Address Maps scope regarding Spectrum * Add intro to cdn-and-spectrum guide * Create outline noting content to be reused with partials * Create partials and apply to new page * Implement conditional content and other improvements * Fill in verify bindings step and review text * Adapt address maps and DNS explanations and add to CDN * Fill in Spectrum instructions and link from CDN section * Overall review and use APIRequest in -create-binding partial * Fix typo * Fix broken link * Apply new partials to mt-with-cdn - previous commit as well * Apply suggestions from code review Co-authored-by: Jun Lee <[email protected]> --------- Co-authored-by: Jun Lee <[email protected]>
1 parent 42b7a40 commit 1c64aeb

File tree

8 files changed

+371
-109
lines changed

8 files changed

+371
-109
lines changed

src/content/docs/byoip/address-maps/index.mdx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,12 @@ Some customers may only proxy zones through BYOIP addresses, and are prohibited
4444

4545
It is still possible to create more specific zone-level address maps with specific BYOIPs, but DNS will fall back to the account-wide address map without one.
4646

47-
To specify different addresses for certain zones, [create a new address map](/byoip/address-maps/setup/).
47+
To specify different addresses for certain zones, [create a new address map](/byoip/address-maps/setup/).
48+
49+
---
50+
51+
## Spectrum compatibility
52+
53+
You can use address maps to set up [non-SNI support](/byoip/address-maps/setup/#spectrum-https-applications) for Spectrum HTTPS applications.
54+
55+
However, to control what IP address Cloudflare will use when responding to requests for your Spectrum applications, you should first refer to their respective configuration and set the `edge_ips` field as `static`. For details, refer to the [Spectrum API](/api/resources/spectrum/models/edge_ips/).
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
---
2+
title: Use BYOIP with CDN and Spectrum
3+
pcx_content_type: tutorial
4+
sidebar:
5+
order: 4
6+
label: CDN and Spectrum
7+
---
8+
9+
import { Render, APIRequest, Details, Example, TabItem, Tabs, GlossaryTooltip } from "~/components";
10+
11+
With [service bindings](/byoip/service-bindings/), CDN[^1] customers using BYOIP can take the same prefix they have onboarded to Cloudflare and use it to selectively route traffic on a per-IP address basis to [Spectrum](/spectrum/)[^2], or vice versa. This means:
12+
13+
- You can upgrade individual IPs within a CDN prefix to a Spectrum IP. For example, if you have a CDN prefix 203.0.113.0/24, you can upgrade 203.0.113.1 to Spectrum.
14+
15+
- You can upgrade individual IPs within a Spectrum prefix to a CDN IP. For example, if you have a Spectrum prefix 203.0.113.0/24, you can upgrade 203.0.113.1 to CDN.
16+
17+
This guide will use the first example and consider a prefix that was onboarded to the CDN, with a few IPs upgraded to Spectrum.
18+
19+
## Before you begin
20+
21+
<Render
22+
file="service-bindings-prereqs"
23+
params={{
24+
pre_existing_product: "CDN",
25+
added_product: "Spectrum"
26+
}}
27+
/>
28+
29+
---
30+
31+
## Prepare your IPs
32+
33+
### 1. Get account information
34+
35+
<Render
36+
file="service-bindings-account-info"
37+
params={{
38+
pre_existing_product: "CDN",
39+
added_product: "Spectrum"
40+
}}
41+
/>
42+
43+
### 2. Create service bindings
44+
45+
<Render
46+
file="service-bindings-create-binding"
47+
params={{
48+
pre_existing_product: "CDN",
49+
added_product: "Spectrum"
50+
}}
51+
/>
52+
53+
### 3. Verify all service bindings
54+
55+
After the propagation time (four to six hours), the [List Service Bindings](/api/resources/addressing/subresources/prefixes/subresources/service_bindings/methods/get/) endpoint should return all service bindings that are part of the prefix - in this case, CDN and Spectrum.
56+
57+
<APIRequest
58+
path="/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings"
59+
method="GET"
60+
/>
61+
62+
---
63+
64+
## Set up your Cloudflare services
65+
66+
### CDN
67+
68+
If you already use BYOIP with CDN, you might be able to skip this step. However, if you are using this guide to upgrade a few IPs from a Spectrum prefix to the CDN, consider the following sections on [address maps](#address-maps) and [DNS records](#dns-records).
69+
70+
:::note
71+
As described below, address maps and DNS records do not apply to Spectrum. To set up your Spectrum application with BYOIP, refer to [Spectrum](#spectrum).
72+
:::
73+
74+
#### Address maps
75+
76+
Use <GlossaryTooltip term="address map" link="/byoip/address-maps/">address maps</GlossaryTooltip> to specify which IPs should be used by Cloudflare in DNS responses when a record is <GlossaryTooltip term="proxy status" link="/dns/proxy-status/">proxied</GlossaryTooltip>.
77+
78+
You can choose between two different scopes:
79+
80+
- Account-level: uses the address map for all proxied DNS records across all of the zones within an account.
81+
- Zone-level: uses the address map for all proxied DNS records within a zone.
82+
83+
:::note
84+
If you need to map only specific subdomains (and not all proxied DNS records) to specific IP addresses, you can use a [Subdomain setup](/dns/zone-setups/subdomain-setup/).
85+
:::
86+
87+
<Tabs syncKey="dashPlusAPI">
88+
<TabItem label="Dashboard" no-code="true">
89+
90+
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/) and select your account.
91+
2. Go to **IP Addresses** > **Address Maps**.
92+
3. Select **Create an address map**.
93+
4. Choose the scope of the address map.
94+
5. Add the zones and IP addresses that you want to map.
95+
6. Name your address map.
96+
7. Review the information and select **Save and Deploy**.
97+
98+
</TabItem>
99+
<TabItem label="API" no-code="true">
100+
101+
Use the [Create Address Map](/api/resources/addressing/subresources/address_maps/methods/create/) endpoint.
102+
103+
Make sure you have the correct Key/Token and permissions.
104+
105+
</TabItem>
106+
</Tabs>
107+
108+
#### DNS records
109+
110+
While the DNS record proxy status and address map will determine how Cloudflare's authoritative DNS responds to requests for your hostnames, the IP addresses specified in `A`/`AAAA` records will determine [how Cloudflare reaches the configured origin](/fundamentals/concepts/how-cloudflare-works/#how-cloudflare-works-as-a-reverse-proxy).
111+
112+
:::note
113+
As you create the necessary DNS records, [Total TLS](/ssl/edge-certificates/additional-options/total-tls/) can help making sure that you have SSL/TLS certificates in place for all your hostnames.
114+
:::
115+
116+
<Tabs syncKey="dashPlusAPI">
117+
<TabItem label="Dashboard" no-code="true">
118+
119+
To create a DNS record in the dashboard:
120+
121+
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/login) and select an account and domain.
122+
2. Go to **DNS** > **Records**.
123+
3. Select **Add record**.
124+
4. Choose an address (`A`/`AAAA`) [record type](/dns/manage-dns-records/reference/dns-record-types/).
125+
5. Complete the required fields, setting the **Proxy status** to **proxied**.
126+
6. Select **Save**.
127+
128+
</TabItem>
129+
<TabItem label="API" no-code="true">
130+
131+
To create records with the API, use a [POST request](/api/resources/dns/subresources/records/methods/create/). For field definitions, select a record type under the request body specification.
132+
133+
</TabItem>
134+
</Tabs>
135+
136+
<Details header="Example">
137+
138+
| Type | Name | IP address | Proxy status | TTL |
139+
| ---- | ----- | --------------- | ------------ | ------ |
140+
| `A` | `www` | `203.0.113.150` | `Proxied` | `Auto` |
141+
142+
At this point, if an address map for a zone `example.com` specifies that Cloudflare should use `203.0.113.100` for proxied records and the above record exists in the same zone, you can expect the following:
143+
144+
1. Cloudflare responds to DNS requests for `www.example.com` with `203.0.113.100`.
145+
2. Cloudflare proxies requests through the CDN and then routes the requests to the origin server `203.0.113.150`.
146+
3. As the HTTP response egresses the Cloudflare network back to the client side, the source IP address of the response becomes `203.0.113.100` (the IP address that the HTTP request originally landed on).
147+
148+
</Details>
149+
150+
:::note
151+
Having the same IP address as ingress IP (defined in the address map) and origin IP (listed in the DNS record) will not cause any loops.
152+
:::
153+
154+
<Details header="Example">
155+
156+
Assuming `203.0.113.100` was also the origin IP, the DNS record would look like the following:
157+
158+
| Type | Name | IP address | Proxy status | TTL |
159+
| ---- | ----- | --------------- | ------------ | ------ |
160+
| `A` | `www` | `203.0.113.100` | `Proxied` | `Auto` |
161+
162+
</Details>
163+
164+
### Spectrum
165+
166+
Configuring Spectrum to use your own IP address is only possible via the [Cloudflare API](/api/resources/spectrum/).
167+
168+
The `origin_direct` field takes the origin IP address, while `edge_ips` allows you to define which IP address from your BYOIP prefix Cloudflare should use to process requests for your Spectrum application.
169+
170+
<APIRequest
171+
path="/zones/{zone_id}/spectrum/apps"
172+
method="POST"
173+
json={[
174+
{
175+
"protocol":"tcp/22",
176+
"dns":{
177+
"type":"CNAME",
178+
"name":"ssh.example.com"
179+
},
180+
"origin_direct":["tcp://192.0.2.1:22"],
181+
"proxy_protocol":"off",
182+
"ip_firewall":true,
183+
"tls":"full",
184+
"edge_ips":{
185+
"type":"static",
186+
"ips":["203.0.113.18"]
187+
},
188+
"traffic_type":"direct",
189+
}
190+
]}
191+
code={{
192+
mark: [17, 18, 19, 20, 21, "203.0.113.18"]
193+
}}
194+
/>
195+
196+
---
197+
198+
## (Optional) Add layer 7 functionality
199+
200+
<Render file="service-bindings-related-products" />
201+
202+
[^1]: Layer 7 HTTP-based
203+
[^2]: Layer 4 or Layer 7 HTTP with custom ports

src/content/docs/byoip/service-bindings/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Customers using BYOIP with Magic Transit, [CDN services](/cache/), or [Spectrum]
2323
- You can upgrade individual IPs within a CDN prefix to a Spectrum IP. For example, if you have a CDN prefix `203.0.113.0/24`, you can upgrade `203.0.113.1` to Spectrum.
2424
- You can upgrade individual IPs within a Spectrum prefix to a CDN IP. For example, if you have a Spectrum prefix `203.0.113.0/24`, you can upgrade `203.0.113.1` to CDN.
2525

26+
Refer to [Magic Transit with CDN](/byoip/service-bindings/magic-transit-with-cdn/) or [CDN and Spectrum](/byoip/service-bindings/cdn-and-spectrum/) for detailed guidance.
27+
2628
:::caution
2729
Magic Transit customers must ensure that their contract includes CDN and/or Spectrum according to their needs.
2830
:::
@@ -31,8 +33,6 @@ Magic Transit customers must ensure that their contract includes CDN and/or Spec
3133

3234
When a service binding of type `CDN` is applied, once the change has propagated across Cloudflare's global network (four to six hours), any HTTP requests are directed into the CDN pipeline for Layer 7 processing.
3335

34-
Refer to [Use BYOIP with Magic Transit and CDN](/byoip/service-bindings/magic-transit-with-cdn/) for detailed guidance.
35-
3636
### Spectrum
3737

3838
When a service binding of type `Spectrum` is applied, once the change has propagated across Cloudflare's global network (four to six hours), any TCP/UDP/HTTP requests are directed into the Spectrum pipeline for Layer 4 or Layer 7 processing.

src/content/docs/byoip/service-bindings/magic-transit-with-cdn.mdx

Lines changed: 25 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -6,120 +6,43 @@ sidebar:
66
label: Magic Transit with CDN
77
---
88

9-
import { Details, Example, TabItem, Tabs, GlossaryTooltip, APIRequest } from "~/components";
9+
import { Details, Example, TabItem, Tabs, GlossaryTooltip, APIRequest, Render } from "~/components";
1010

11-
[Magic Transit](/magic-transit/) customers using BYOIP can also benefit from the performance, reliability, and security that Cloudflare offers for HTTP-based applications.
11+
[Magic Transit](/magic-transit/) customers using BYOIP can also benefit from the performance, reliability, and security that Cloudflare offers for HTTP-based applications. [Service bindings](/byoip/service-bindings/) allow BYOIP customers to selectively route traffic on a per-IP address basis to the CDN pipeline (which includes [Cache](/cache/), [Web Application Firewall (WAF)](/waf/), and more).
1212

13-
This documentation covers using the Cloudflare API to configure [service bindings](/byoip/service-bindings/) within Cloudflare's IP Address Management framework. Service bindings allow BYOIP customers to selectively route traffic on a per-IP address basis to the CDN pipeline (which includes [Cache](/cache/), [Web Application Firewall (WAF)](/waf/), and more).
14-
15-
It is also possible to define service bindings to route traffic to the Spectrum pipeline selectively. However, this is not in the scope of this guide.
13+
This guide covers using the Cloudflare API to configure Magic Transit with CDN. It is also possible to define service bindings to route traffic to the Spectrum pipeline selectively. Refer to [scope](/byoip/service-bindings/#scope) for the full list of possible configurations and other available guides.
1614

1715
It is important to note that traffic routed to the CDN pipeline is protected at Layers 3 and 4 by the inherent DDoS protection capabilities native to the CDN pipeline.
1816

1917
## Before you begin
2018

21-
Although it is possible to add discrete bindings for non-contiguous CIDR blocks, implementing service bindings through an **aggregated** CIDR block is **strongly** recommended as it is more efficient.
22-
23-
<Details header="Example">
24-
25-
**Magic Transit protected prefix:** `203.0.113.0/24`
26-
27-
**IPs to upgrade to the CDN:**
28-
29-
`203.0.113.16`<br />
30-
`203.0.113.17`<br />
31-
`203.0.113.18`<br />
32-
`203.0.113.19`<br />
33-
`203.0.113.20`<br />
34-
`203.0.113.21`<br />
35-
`203.0.113.22`<br />
36-
`203.0.113.23`
37-
38-
Add one discrete CDN service binding for `203.0.113.16` with a `/29` netmask.
39-
40-
</Details>
41-
42-
Once a service binding is created (or deleted), it will take **four** to **six** hours to propagate across Cloudflare's global network. Services for the IP addresses in scope will likely be disrupted during this window.
43-
44-
:::note
45-
This guide assumes that the prefix is tied to a single Cloudflare account that has both Magic Transit and CDN properties. If you are using [prefix delegations](/byoip/concepts/prefix-delegations/), the service bindings must be [created](#2-create-service-binding) on the parent account.
46-
:::
19+
<Render
20+
file="service-bindings-prereqs"
21+
params={{
22+
pre_existing_product: "Magic Transit",
23+
added_product: "CDN"
24+
}}
25+
/>
4726

4827
## 1. Get account information
4928

50-
1. Log in to your Cloudflare account and get your [account ID](/fundamentals/account/find-account-and-zone-ids/) and [API token](/fundamentals/api/get-started/create-token/). The token permissions should include `Account` - `IP Prefixes` - `Edit`.
51-
2. Make a `GET` request to the [List Services](/api/resources/addressing/subresources/services/methods/list/) endpoint and take note of the `id` associated with the CDN service.
52-
3. Use the [List Prefixes](/api/resources/addressing/subresources/prefixes/methods/list/) endpoint and take note of the `id` associated with the prefix (`cidr`) you will configure.
53-
54-
<Example>
55-
56-
At this point, continuing the [example](#before-you-begin), you should have a mapping similar to the following:
57-
58-
| Variables | Description |
59-
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
60-
| `{service_id}` | The ID of the CDN service within Cloudflare. <br /><br /> Example: `969xxxxxxxx000xxx0000000x00001bf` |
61-
| `{prefix_id}` | The ID of the Magic Transit protected prefix (`203.0.113.0/24`) you want to configure. <br /><br /> Example: `6b25xxxxxxx000xxx0000000x0000cfc` |
62-
63-
</Example>
64-
65-
4. To confirm you currently only have a Magic Transit service binding and that it spans across your entire prefix, make a `GET` request to the [List Service Bindings](/api/resources/addressing/subresources/prefixes/subresources/service_bindings/methods/list/) endpoint. Replace the `{prefix_id}` in the URI path by the actual prefix ID you got from the previous step.
66-
67-
<Example>
68-
69-
```bash
70-
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings \
71-
--header "Authorization: Bearer <API_TOKEN>"
72-
```
73-
74-
</Example>
29+
<Render
30+
file="service-bindings-account-info"
31+
params={{
32+
pre_existing_product: "Magic Transit",
33+
added_product: "CDN"
34+
}}
35+
/>
7536

7637
## 2. Create service binding
7738

78-
:::caution[Caution]
79-
Once a service binding is created (or deleted), it will take four to six hours to propagate across Cloudflare's global network. Services for the IP addresses in scope will likely be disrupted during this window.
80-
:::
81-
82-
1. Make a `POST` request to the [Create service binding](/api/resources/addressing/subresources/prefixes/subresources/service_bindings/methods/create/) endpoint, indicating the IP address you want to bind to the CDN. Specify the **corresponding network mask** as needed.
83-
84-
<Example>
85-
86-
Continuing the example, `203.0.113.100/32` designates an IP address that is within the Magic Transit protected prefix `203.0.113.0/24`.
87-
88-
Replace the `{prefix_id}` in the URI with your prefix ID from previous steps. Within the request body, the `cidr` value should correspond to the IP address or subnet that you are configuring for use with CDN.
89-
90-
```bash
91-
92-
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings \
93-
--header "Authorization: Bearer <API_TOKEN>" \
94-
--header "Content-Type: application/json" \
95-
--data '{
96-
"cidr": "203.0.113.100/32",
97-
"service_id": "<SERVICE_ID>"
98-
}'
99-
```
100-
101-
In the response body, the initial provisioning state should be `provisioning`.
102-
103-
```json output {9}
104-
{
105-
"errors": [],
106-
"messages": [],
107-
"success": true,
108-
"result": {
109-
"cidr": "203.0.113.100/32",
110-
"id": "<CDN_SERVICE_BINDING_ID>",
111-
"provisioning": {
112-
"state": "provisioning"
113-
},
114-
"service_id": "<SERVICE_ID>",
115-
"service_name": "CDN"
116-
}
117-
}
118-
```
119-
120-
</Example>
121-
122-
You can periodically check the service binding status using the [List Service Bindings](/api/resources/addressing/subresources/prefixes/subresources/service_bindings/methods/list/) endpoint.
39+
<Render
40+
file="service-bindings-create-binding"
41+
params={{
42+
pre_existing_product: "Magic Transit",
43+
added_product: "CDN"
44+
}}
45+
/>
12346

12447
## 3. Create address maps
12548

@@ -218,8 +141,4 @@ Assuming `203.0.113.100` was also the origin IP, the DNS record would look like
218141

219142
## 5. (Optional) Add layer 7 functionality
220143

221-
Leverage other features according to your needs:
222-
223-
- [Cache](/cache/)
224-
- [WAF custom rules](/waf/custom-rules/)
225-
- [Security analytics](/waf/analytics/security-analytics/)
144+
<Render file="service-bindings-related-products" />

0 commit comments

Comments
 (0)