cloudflare-docs icon indicating copy to clipboard operation
cloudflare-docs copied to clipboard

Cloudflare for Saas Workers origin

Open garretcharp opened this issue 3 years ago • 7 comments

Which Cloudflare product does this pertain to?

Cloudflare for SaaS

Existing documentation URL(s)

  • https://developers.cloudflare.com/cloudflare-for-saas/workers-for-platforms/worker-as-origin/

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

garretcharp avatar Aug 21 '22 23:08 garretcharp

Howdy @rita3ko, can you help with this?

kodster28 avatar Aug 22 '22 15:08 kodster28

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

rita3ko avatar Aug 23 '22 14:08 rita3ko

cc @dinasaur404

rita3ko avatar Aug 23 '22 15:08 rita3ko

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.

kabirsikand avatar Aug 23 '22 17:08 kabirsikand

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 avatar Aug 24 '22 00:08 garretcharp

@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.

garretcharp avatar Apr 29 '23 14:04 garretcharp

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/

henrhoi avatar Apr 24 '24 08:04 henrhoi