Get origin hostname on origin when content is retrieved

Hi,

I am wondering if the following is possible. We serve a multi-tenant site that selects the correct tenant based on the host subdomain name (e.g. c1.example.com might be customer1 and c2.example.com might be customer2).

We were hoping to use DNS to enable us to serve c1.example.com from, e.g. www.customer1.com and c2.example.com from www.customer2.com to support vanity domains. We have setup the CNAMES in DNS correctly, but there doesn’t seem to be a way to get the host name of the origin server when the Cloudflare proxy retrieves from the origin. When a user visits www.customer1.com (which has a CNAME that points to c1.example.com), we would like the origin site hosted at c1.example.com to know what origin host name origin was mapped in DNS (i.e. we would like to be able to get the value c1.example.com when someone visits www.customer1.com).

Is this scenario possible or supported or is there perhaps something obvious that I’m missing?

Regards,

ismart

Is there a header or some other way we can get hold of the mapped origin host name from the origin server?

:wave: @gavind,

Allowing an arbitrary hostname to cname to a domain you control is a feature of Cloudflare’s SSL for SaaS product.

https://developers.cloudflare.com/ssl/ssl-for-saas/hostname-specific/custom-metadata/

This is an optional (extra) feature for the SSL for SaaS platform. When you provision the custom hostname you can include additional metadata (via API only) and that information is then accessible to a worker. I believe you may also be able to rewrite the host header to the value of the CNAME target (assuming it is in your proxy zone) as well if that would be easier.

If you contact the Cloudflare sales team, one of their solutions engineers might be able to provide better information/context than a random pug on the interwebs.

– OG

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.