cloudflare / cloudflare-docs

Cloudflare’s documentation
https://developers.cloudflare.com
Creative Commons Attribution 4.0 International
2.97k stars 3.85k forks source link

Cloudflare for Saas Workers origin #5584

Open garretcharp opened 2 years ago

garretcharp commented 2 years ago

Which Cloudflare product does this pertain to?

Cloudflare for SaaS

Existing documentation URL(s)

Section that requires update

Point #4

What needs to change?

It currently states that if you want all traffic on your zone to go to the worker to set a route pattern as */* going to the worker (this part is correct). However it says if you do not want that to set the route *.<zonename>.com/* to no worker. When in actuality you need to see both the */* route to the worker and *.<zonename>.com/* to no worker otherwise all your customers domains would get error 522.

How should it change?

Needs to give accurate info on how to setup the worker origin if you do not want everything on your zone to go to the saas handler worker. Had to debug this quite a bit in discord to get it to properly work because it was either getting error 522 or overriding all of my other workers previously and any other origins that might be setup that proxy through cloudflare.

Additional information

No response

kodster28 commented 2 years ago

Howdy @rita3ko, can you help with this?

rita3ko commented 2 years ago

@tanushree-sharma @kabirsikand what's the right answer here?

rita3ko commented 2 years ago

cc @dinasaur404

kabirsikand commented 2 years ago

The updated guidance here is to use Custom Domains to route traffic on a zone to the Worker, by setting the custom domain as a fallback origin or custom origin for your custom hostnames (e.g. worker.example.com); this however will also route traffic on that domain name (worker.example.com) to the worker. In that regard it is different than both methods listed on the documentation now.

garretcharp commented 2 years ago

Even when using custom domains you must still have a route of */* otherwise you will get the following error (522): image

And if you dont want your entire zone to be taken over by the SASS worker you need to add 2 worker exclusions in your zone settings and the */* route So you would need all of the following:

<zonename>.com/* -> no worker
*.<zonename>.com/* -> no worker
*/* -> sass worker
garretcharp commented 1 year ago

@kabirsikand is there any update on this? People still get confused by this in the Cloudflare Dev Discord. Would be nice to update docs here to show how to set this up properly and to update that the worker routes page now calls it a "service" in the route selection menu.

henrhoi commented 5 months ago

Struggled for a day, before finding this issue. Would be great to have this mentioned in https://developers.cloudflare.com/workers/configuration/routing/custom-domains/