Serving content through custom hostnames that are pointed to a Cloudflare Worker

Hi, I’m trying to follow this guide in order to set up custom hostnames with a CF Worker:

https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/worker-as-origin/

I’m running into the exact same problem as this issue I found on the forums in the past:

https://community.cloudflare.com/t/how-to-properly-set-up-a-custom-hostname-with-a-worker/329219

It seems like this was a bug that was fixed by the Cloudflare team in the past but I have the same setup as that person and I’m getting the same 522 error.

My setup:

  • workerName.workers.dev worker with a worker route of proxy.mywebsite.com/* pointing to the worker.
  • I have proxy.mywebsite.com set up as a fallback origin in Custom Hostnames.
  • I have a AAAA record for proxy with a content of 100:: on mywebsite.com, like the Cloudflare document above describes
  • I set up a Cloudflare Custom Hostname for customerwebsite.com. The certificate status and hostname status is Active.
  • On the customer DNS side, I have a CNAME record for www with a value of proxy.mywebsite.com.

I would assume that customer CNAME would mean any time someone accesses customerwebsite.com, the CNAME to proxy.mywebsite.com would cause Cloudflare to route that to the worker.

curl -I https://www.customerwebsite.com/ returns a 522

curl -I https://proxy.mywebsite.com/ returns a 200 and I see the request in Cloudflare

Does Cloudflare still support using a worker as the fallback origin for custom hostnames? Does this not work when trying to serve custom hostnames from ONLY proxy.mywebsite.com? I have other endpoints like api.mywebsite.com and app.mywebsite.com that I do not want to serve custom hostnames from. Do I need to use a different domain to serve custom hostnames from? For example, proxy.mywebsite.cloud instead of proxy.mywebsite.com?

1 Like