Possible to use the "Custom Hostnames" feature with CNAMEs pointing to a worker?

We are trying to move our click tracking over to CloudFlare workers instead of our current server-side setup. We have set up a new worker which is currently able to receive clicks correctly and process them. That worker is available from both the root domain EXAMPLE.workers.dev as well as a custom domain we attached worker.EXAMPLE.net. Our current server-side setup users Custom Hostnames to allow our customers to point a CNAME at our domain and we wanted to do the same with the new webworker. I set up a Custom Hostname on the EXAMPLE.net domain: Fallback Origin: worker.EXAMPLE.net Custom Hostname: testing.EXAMPLE.com However, when I do this, the domain gives me a 522 "Connection timed out" error. Is it possible to use Custom Hostnames with CF workers?
2 Replies
Chaika
Chaika•14mo ago
Yea it's possible, just need a bit of a custom setup: https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/start/advanced-settings/worker-as-origin/ The worker route/custom domain sees the traffic as coming in as testing.example.com, thus it would only match wildcard routes like in there
Workers as your fallback origin · Cloudflare for Platforms docs
Learn how to use a Worker as the fallback origin for your SaaS zone.
harisenbon
harisenbonOP•14mo ago
🥳 will check that out and see if I can get that running Worked! Thanks so much.
Want results from more Discord servers?
Add your server