HTTP 522 when using Worker as fallback origin for Cloudflare for SaaS

I'm trying to use a Cloudflare Worker as my fallback origin for Cloudflare for SaaS. I have the worker registered with a custom domain at fallback.mydomain.com. When I hit it directly, I see the response from the Worker. I then have fallback.mydomain.com registered as my fallback origin in SSL/TLS > Custom Hostnames. I have a custom domain registered (different zone, under the same account) and the certificate and hostname status are "Active", but when I hit the custom domain I get an HTTP 522 back.
5 Replies
maxdeviant
maxdeviantOP•5mo ago
I should also note that I was able to reproduce the problem without the custom hostname by following the advice suggested in the Cloudflare for SaaS setup guide. I created a CNAME record cname.mydomain.com that points to fallback.mydomain.com (proxied), but if I go to cname.mydomain.com in the browser I also get an HTTP 522 back.
maxdeviant
maxdeviantOP•5mo ago
I also used the trace tool to debug this, and when I trace https://fallback.mydomain.com I see it matches the worker:
No description
maxdeviant
maxdeviantOP•5mo ago
But if I trace https://cname.mydomain.com then it matches nothing, and returns the 522
No description
Chaika
Chaika•5mo ago
You need a worker route matching everything: https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/start/advanced-settings/worker-as-origin/ Just be careful to exclude your own domain as it suggests, or more preferability use an entirely seperate domain/zone for SaaS customers setups
Cloudflare Docs
Workers as your fallback origin
Learn how to use a Worker as the fallback origin for your SaaS zone.
maxdeviant
maxdeviantOP•5mo ago
Ah yes, that makes sense! Thanks for the quick reply That did the trick 🙂

Did you find this page helpful?