Hello, how works CNAME records from non cloudflare domains to cloudflare domains? If I try to create CNAME record subdomain.noncloudflarehosteddomain → subdomain.cloudflarehosteddomain I have error Error 1014. I know some websites, who allowed CNAME records from non cloudflare domain to cloudflare domain. For example instapage(dot)com allows custom domains to be pointed to secure(dot)pageserve(dot)co but I don’t know how they do it.
Its very important for our business. Thank you very much for your help.
If you want to create a CNAME record to a Cloudflare domain, the owner of the Cloudflare domain needs to allow this by using Cloudflare for SaaS. An exception to that is if both domains are in the same Cloudflare account.
1 Like
Hello, thank you @Laudian for your reply.
Its working for single fallback origin, but my issue is different:
Now its working:
CNAME: customer-domain(dot)com → region1(dot)ourdomain(dot)com and fallback origin region1(dot)ourdomain(dot)com - Working perfectly.
The task is
CNAME: second-customer-domain(dot)com → region2(dot)ourdomain(dot)com and the traffic must be redirect to region2(dot)ourdomain(dot)com , not to fallback origin region1(dot)ourdomain(dot)com
CNAME: third-customer-domain(dot)com → region3(dot)ourdomain(dot)com and the traffic must be redirect to region3(dot)ourdomain(dot)com , not to fallback origin region1(dot)ourdomain(dot)com
CNAME: fourth-customer-domain(dot)com → region4(dot)ourdomain(dot)com and the traffic must be redirect to region4(dot)ourdomain(dot)com , not to fallback origin region1(dot)ourdomain(dot)com
etc…
Can I setup this with cloudflare workers or other solution/service, not with multiple fallback origins, because they are included included in in Enterpise plans?
Thank you very much for your time.
All best!
That should be possible, look at the following documentation.
You set a Worker as your fallback Origin and then load the site from the actual Origin.
You’d obviously have to modify the worker each time you add a new site/origin.
Dear @Laudian , thank you very much again for your reply and help.
Here is my worker code, everything looks working as expected but I have issue:
If I run phpinfo to watch all headers, the worker working correctly, but in phpinfo I don’t see the source domain, I see only the target (cloudflare) domain.
For this example:
‘my-noncloudflare(.)domain(.)com’: ‘(https)://my(.)cloudflaredomain(.)com’ in phpinfo I see my(.)cloudflaredomain(.)com as headers, not my-noncloudflare(.)domain(.)com How can I restore the source domain? Thank you for the help!
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
// Get the hostname from the request header
const url = new URL(request.url);
const hostname = url.hostname;
// Map the hostname to the target region
const regionMap = {
'my-noncloudflare(.)domain(.)com': '(https)://my(.)cloudflaredomain(.)com',
'my-noncloudflare(.)other-domain(.)com': '(https)://mysecond(.)cloudflaredomain(.)com',
// Add more mappings as needed
};
// Find the target region, or default to default server if not found
const targetRegion = regionMap[hostname] || 'https://my(.)cloudflaredomain(.)com';
// Modify the request to point to the target region
const newRequest = new Request(targetRegion + url.pathname + url.search, request);
// Fetch the request from the target region
const response = await fetch(newRequest);
// Return the response from the target region
return response;
}
BTW I add (.) in URLs, because here is not allowed to add URL/Links to other sites.
Somebody can help about this case?
Thank you everyone.