mirror of
https://github.com/cloudflare/cloudflare-docs.git
synced 2026-01-11 20:06:58 +00:00
Clarify custom hostname routing for Worker as origin (#27424)
* Clarify custom hostname routing for Worker as origin Addresses the lack of clarity about how custom hostname traffic reaches Workers when using Cloudflare for SaaS. Changes: - Add new section explaining how custom hostname traffic flows through the SaaS zone - Provide concrete example showing the relationship between SaaS zone, fallback origin, custom hostname, and Worker route - Clarify that wildcard route pattern (*/*) automatically captures custom hostname traffic - Rewrite step 4 with clearer routing options and examples - Add related resources section linking to hostname routing and Workers routes docs Fixes #27397 * Added case of only some hostnames to worker (#27425) * Added case of only some hostnames to worker * Removed copied line --------- Co-authored-by: Isak Wang Gustavsen <69854945+isakgustavsen@users.noreply.github.com>
This commit is contained in:
parent
9277762e6e
commit
1100db242a
1 changed files with 38 additions and 10 deletions
|
|
@ -7,32 +7,55 @@ head:
|
|||
- tag: title
|
||||
content: Workers as your fallback origin
|
||||
description: Learn how to use a Worker as the fallback origin for your SaaS zone.
|
||||
|
||||
---
|
||||
|
||||
import { Render } from "~/components";
|
||||
|
||||
If you are building your application on [Cloudflare Workers](/workers/), you can use a Worker as the origin for your SaaS zone (also known as your fallback origin).
|
||||
|
||||
1. In your SaaS zone, [create and set a fallback origin](/cloudflare-for-platforms/cloudflare-for-saas/start/getting-started/#1-create-fallback-origin). Ensure the fallback origin only has an [originless DNS record](/dns/troubleshooting/faq/#what-ip-should-i-use-for-parked-domain--redirect-only--originless-setup):
|
||||
## How custom hostname traffic reaches your Worker
|
||||
|
||||
* **Example**: `service.example.com AAAA 100::`
|
||||
When customers point their domains to your SaaS zone (for example, `mystore.customer.com` CNAMEs to `service.saasprovider.com`), their traffic enters your Cloudflare zone. Any Worker routes configured on your zone will match this incoming traffic.
|
||||
|
||||
For example, if you have:
|
||||
|
||||
- Your SaaS zone: `saasprovider.com`
|
||||
- Your fallback origin: `service.saasprovider.com`
|
||||
- Customer's custom hostname: `mystore.customer.com` (pointed to your zone via CNAME)
|
||||
- Worker route: `*/*`
|
||||
|
||||
When a visitor requests `mystore.customer.com`, Cloudflare routes that request through your zone. The `*/*` route pattern matches all traffic entering your zone, including traffic from custom hostnames like `mystore.customer.com`.
|
||||
|
||||
:::note
|
||||
You do not need to add individual Worker routes for each custom hostname. The wildcard route pattern (`*/*`) automatically captures all traffic entering your zone, including traffic from customer vanity domains.
|
||||
:::
|
||||
|
||||
## Set up a Worker as your fallback origin
|
||||
|
||||
1. In your SaaS zone, [create and set a fallback origin](/cloudflare-for-platforms/cloudflare-for-saas/start/getting-started/#1-create-fallback-origin). Ensure the fallback origin only has an [originless DNS record](/dns/troubleshooting/faq/#what-ip-should-i-use-for-parked-domain--redirect-only--originless-setup):
|
||||
- **Example**: `service.example.com AAAA 100::`
|
||||
|
||||
2. In that same zone, navigate to **Workers Routes**.
|
||||
|
||||
3. Click **Add route**.
|
||||
|
||||
4. Decide whether you want traffic bound for your SaaS zone (`example.com`) to go to that Worker:
|
||||
4. Configure a route to send traffic to your Worker. Choose one of the following options based on your needs:
|
||||
- **Route all traffic to the Worker** (recommended for most SaaS applications):
|
||||
- **Route**: `*/*`
|
||||
- **Worker**: Select the Worker used for your SaaS application.
|
||||
|
||||
* If *yes*, set the following values:
|
||||
This pattern routes all traffic entering your zone to the Worker, including requests from custom hostnames (for example, `mystore.customer.com`) and requests to your own subdomains (for example, `app.saasprovider.com`).
|
||||
|
||||
* **Route**: `*/*` (routes everything — including custom hostnames — to the Worker).
|
||||
* **Worker**: Select the Worker used for your SaaS application.
|
||||
- **Route all but specific routes to worker**:
|
||||
- **Route**: `*/*`
|
||||
- **Worker**: Select the Worker used for your SaaS application.
|
||||
- Add a second route for your zone's own hostnames with **Worker** set to **None** to exclude them.
|
||||
|
||||
* If *no*, set the following values:
|
||||
For example, if your zone is `saasprovider.com` and you want `api.saasprovider.com` to bypass the Worker, create an additional route `api.saasprovider.com/*` with no Worker assigned. More specific routes take precedence over wildcard routes.
|
||||
|
||||
* **Route**: `*.<zonename>.com/*` (only routes custom hostname traffic to the Worker)
|
||||
* **Worker**: **None**
|
||||
- **Route only custom hostname traffic to the Worker**:
|
||||
- **Route**: `vanity.customer.com`
|
||||
- **Worker**: Select the Worker used for your SaaS application.
|
||||
|
||||
5. Click **Save**.
|
||||
|
||||
|
|
@ -43,3 +66,8 @@ If you are building your application on [Cloudflare Workers](/workers/), you can
|
|||
<Render file="same-name-as-zone" product="cloudflare-for-platforms" />
|
||||
|
||||
:::
|
||||
|
||||
## Related resources
|
||||
|
||||
- [Hostname routing](/cloudflare-for-platforms/workers-for-platforms/configuration/hostname-routing/) - Learn about advanced routing patterns, including dispatch Workers and Orange-to-Orange (O2O) behavior.
|
||||
- [Workers routes](/workers/configuration/routing/routes/) - Learn more about route pattern matching and validity rules.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue