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
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.I also used the trace tool to debug this, and when I trace
https://fallback.mydomain.com I see it matches the worker:
But if I trace
https://cname.mydomain.com then it matches nothing, and returns the 522
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.
Ah yes, that makes sense! Thanks for the quick reply
That did the trick 🙂