CNAME to a URL in Cloudflare then web forwarding

Hi, I’ve got some forwarding to set up which doesn’t seem to work in the hosting account’s DNS, so I wonder if Cloudflare (free plan) could do it. Here’s how it needs to work:

domain1.com (in Cloudflare)
subdomain.domain2.com C-NAME points to domain1.com (Cloudflare)
Both need to (wildcard) forward to a specific page on another site

Would setting up the latter as a C-NAME mean the forwarding would work on the subdomain too?

(I’m having to type in C-NAME as it counts it as a link).

I did not understand do you mean you want to redirect domain.com to subdomain.com ?

Thanks very much.

I want to redirect both domain1.com (which is no problem) and subdomain.domain2.com (which is set up as a C-NAME of domain1.com) to a page on a separate site. It’s the bit about the subdomain set up as a C-NAME which doesn’t seem to work at the moment.

you want to redirect ? from domain.com to subdomain.com to anotherdomain.com right ?

That’s a bit confusing

Sorry if a misunderstand your issue

Using page rules to perform redirects perhaps.

1 Like

Hi,

If you have tried this using Page Rules, please let us know what error you see.

If the problem is a mismatch with host headers, here is an option:

Overriding host headers without an Enterprise plan requires implementing a Cloudflare Worker to rewrite the origin host header to your needs. Specifically you will want to take a look at Static Site Hosting for a recipe you can cater towards your use case.

You can follow this article Fetching object storage assets through the Cloudflare CDN using a Cloudflare Worker, for specific directions.

Essentially you will want to:

  1. Create a subdomain in your DNS records that points to your 3rd party origin (img, cdn, etc).
    For example:
Type: CNAME
Name: cdn
Value: 3rd party origin
  1. Use the Static Site Hosting worker, remember to change the fetch at the bottom to your 3rd party origin.
  2. Create a Route for your worker to be available on the subdomain you just created. ex: cdn.example.com/*
  3. Change any HTML references for the 3rd party to cdn.example.com

Another option is SSL for SaaS.

Yes I know it’s confusing. I don’t have access to the subdomain, so the best I can do is to get it to be a C-NAME of a domain I do have full DNS access to, and do the actual web forwarding to the 3rd domain somewhere else, so I’m trying to find out whether that would work in Cloudflare.

I’ve tried this on Cloudflare now and I’m getting error 1001, Error 1001: DNS resolution error
n.

  • An external domain that is not on using Cloudflare has a CNAME record to a domain active on Cloudflare
    I can’t add the subdomain’s domain to Cloudflare. Is there any way around this otherwise?

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