Custom Hostnames
Hii,
So im quite new to this custom hostnames thing and in fact it is my first time using it. Now my priority is that the end user has to do as few as possible. I played a bit around with the API and now i am a bit confused. When i add a new Hostname it verifies it automatically without me doing anything but adding the hostname via api. I mean that's good and all but is it meant to be like that? Since im using the HTTP validation the api returns also something called "http_url" and "http_body". (POST https://api.cloudflare.com/client/v4/zones/ZONE_ID/custom_hostnames) I wonder if it verifies the domain automatically what is the point of it then? Can that be because i basically used a subdomain and didn't use an entirely different domain? Or is that intended?
I also noticed that if i point my subdomain directly to the fallback origin directly it works just fine. So what is really the point of the custom hostnames?
6 Replies
I also noticed that if i point my subdomain directly to the fallback origin directly it works just fine. So what is really the point of the custom hostnames?Same Cloudflare account it will. Other CF Accounts or external zones it won't (for security reasons, and also because you need ssl/tls)
Since im using the HTTP validation the api returns also something called "http_url" and "http_body". (POST https://api.cloudflare.com/client/v4/zones/ZONE_ID/custom_hostnames) I wonder if it verifies the domain automatically what is the point of it thenIf you didn't want them to switch over until it is verified, and you had control over their origin server, you could place the token at the url to pre-validate it. If you're having them switch with potential downtime while stuff validates/certs are issued, all they have to do is add the cname yea
Thanks. That means i don't have to do anything except sending the api request to add the custom hostname right?
As long as you're fine with some potential downtime on setup/switch over, you can just do that and setup the cname yea: https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/hostname-validation/realtime-validation/
Cloudflare Docs
Real-time validation methods - Custom Hostname Validation · Cloudf...
When you use a real-time validation method, Cloudflare verifies your customer's hostname when your customers adds their DNS routing record to their authoritative DNS.
Alright thanks. Another question: Is there any way i can get the domain the request came from? So i can identify the user that the domain is registered to in my database? The 'Host' header doesn't seem to do that.
Host header should be the same as the request, I've tested with Workers and a normal origin w/ that before. Perhaps your setup is overwriting it/doing something weird?
Alright will check. My guess is that nginx is overwriting it
Yep that was the issue. Thank you so much for you help! :pandalove: