host header

I set up a load balancer but need to set the Host Headers so (region)cdn.x.com point to cdn.x.com without getting a CNAME error. I'm not completely sure how to do it, I saw some documents on it but I'm confused. Can someone give me a simple walk through?
17 Replies
Chaika
Chaika7mo ago
If you're using Cloudflare's Load Balancer you can override the host header of a specfic per Origin in a Pool even without Enterprise: https://developers.cloudflare.com/load-balancing/additional-options/override-http-host-headers/ There's more restrictions on it though:
For security reasons, this header must meet one of the following criteria: Is a subdomain of a zone associated with this account Matches the origin address Publicly resolves to the origin address
Override HTTP Host headers · Cloudflare Load Balancing docs
When your application needs specialized routing (CNAME setup or custom hosts like Heroku), you can customize the Host header used in health monitors …
Chaika
Chaika7mo ago
It's under Manage Pools -> Edit, and then the Origins settings
Chaika
Chaika7mo ago
No description
Chaika
Chaika7mo ago
(forgot to use reply, @Honorme )
Honorme
Honorme7mo ago
The problem is, its a R2 bucket so I cannot edit it on that page you screenshotted. I lied. I was looking in the wrong place.
Chaika
Chaika7mo ago
hmm R2 is special because it uses CF for SaaS under it, lots of special Cloudflare magic making it work, not a normal origin You could try though. I believe Pages does work if you override it to the pages.dev, R2 might work as well, not something I've tried
Honorme
Honorme7mo ago
The header address is the subdomain I'm using for the load balancer correct?
No description
Honorme
Honorme7mo ago
Asiacdn is the region, Hascdn is the main URL I'm using, then using geo steering.
Chaika
Chaika7mo ago
I would use whatever you have added in the R2 Custom Domains tab if it's asiacdn you could try overriding it to that (I'm assuming this is an R2 Custom Domain and not a Worker)
Honorme
Honorme7mo ago
Correct
Chaika
Chaika7mo ago
hmm yea I don't think you'll be able to get this working with R2 Custom Domains. With Cloudflare Pages (which I'm using as an example because it's also a Cloudflare product using CF for SaaS under the hood, although with slightly different magic) you can override the Host header to the real pages.dev url and it accepts it (I think because same account or something), but R2 isn't setup like that/the same way. The CNAMEs technically go to public.r2.dev but it won't accept that Under the hood this is all CF for SaaS magic, the R2 Custom Domain has what you could think of an allowlist for specific host headers, LB is too late though or something, and it just doesn't work I know people have accomplished this before just using Workers -- either to just route and fetch the r2 custom domain, or with the R2 Binding. When Snippets come out it would be cheaper/wouldn't have to pay for Worker Invocations. If you have control over the client (like downloading via JS, or from a program), you could just do the routing client-side
Honorme
Honorme7mo ago
No description
Honorme
Honorme7mo ago
even if I do that, for example: customdomain.mydomain.us -> hascdn.mydomain.us it still gives the same error
Chaika
Chaika7mo ago
Yea.. see my comment above, I don't think you'll be able to use LB for this
Honorme
Honorme7mo ago
Yeah I tried it without the LB and had the same outcome
Chaika
Chaika7mo ago
delete the LB entirely (if it exists on that hostname) and any record, and then add it via the R2 Custom Domain tab of the bucket and you'll also want to give it a second to work I should probably clarify as well "CF for SaaS" is Cloudflare for SaaS (https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/), a Cloudflare product which would allow you to have your Customers point their domains at your Cloudflare domain, and have Cloudflare handle SSL and routing. Cloudflare for SaaS is used internally by various Cloudflare products to enable you to use your own domain with them. It works pretty well but it has interesting quirks like it not playing nicely with LB, and overriding some settings like min tls. Technically requests go through both your website and also the R2 Domain (which is a separate website/zone with its own settings)
Honorme
Honorme7mo ago
I appreciate the responses, it appears that it won't do what I need then since I'm pretty much trying to create a global CDN using R2 buckets and steering but it appears that's not doable.
Want results from more Discord servers?
Add your server
More Posts