16

I'm currently using Amazon CloudFront as a CDN for my images on a subdomain img.example.com, from an origin origin.example.com.

I recently saw that CloudFlare provide a CDN for a flat fee so I'm interested in trying them out. But when I log in the only option is to add my main domain example.com and not the origin. Here's the error:

We were unable to identify origin.example.com as a registered domain. Please ensure you are providing the root domain and not any subdomains (e.g., example.com, not subdomain.example.com) (Code: 1099)

I don't want to route my whole site traffic through CloudFlare, only the image subdomain. Is this possible?

2 Answers 2

8

Yes: add the root domain, then you can select which subdomains to route through CloudFlare in the DNS tab, at which point you can disable CloudFlare on the domain and enable it on the subdomains by clicking the cloud icon next to the relevant DNS record.

In this example, I have georgegarside.com through CloudFlare and server.georgegarside.com bypassing CloudFlare, however this can be reversed by clicking the cloud icons on the right.

A gray cloud means that the traffic is not passing through the CloudFlare network.

Source: https://support.cloudflare.com/hc/en-us/articles/200168756-How-do-I-add-a-subdomain-

5
  • When I do that it's still asking me to change the DNS for the entire domain. Commented Sep 6, 2015 at 15:41
  • 1
    @DisgruntledGoat Yes, CloudFlare manages the DNS. Once you have the DNS set up with CloudFlare, you can manage the CloudFlare status for each entry independently (see edit to answer).
    – grg
    Commented Sep 6, 2015 at 15:46
  • OK I misunderstood what changing the DNS does. Thanks, I get it now. Commented Sep 6, 2015 at 16:06
  • 2
    Note, CloudFlare don't allow this in their Terms of Use. Commented Sep 7, 2015 at 10:00
  • 2
    @AndrewLott Actually it is fine. I contacted CF and they said as long as the files are being used on a website there is no problem. Been using CF for months now with no problems. Commented Jun 15, 2016 at 16:17
7

CloudFlare don't allow this in their Terms of Use. I received the following email from CloudFlare when I attempted this on an image-only subdomain once:

Also note here -- you seem to only be using CloudFlare for this products.xyzmedia.co.uk subdomain. We do not permit CloudFlare to be used only for static file delivery. You will need to have xyzmedia.co.uk or www.xyzmedia.co.uk resolving and proxied by CloudFlare to continue using our service. This is outlined in section 10 of our Terms of Service.

The current version (October 26, 2018) of the terms specifically notes:

The Service is offered primarily as a platform to cache and serve web pages and websites. Unless explicitly included as a part of a Paid Service purchased by you, you agree to use the Service solely for the purpose of serving web pages as viewed through a web browser or other application and the Hypertext Markup Language (HTML) protocol or other equivalent technology. Use of the Service for the storage or caching of video (unless purchased separately as a Paid Service) or a disproportionate percentage of pictures, audio files, or other non-HTML content, is prohibited.

4
  • Thanks, I had a feeling there would be a catch like this somewhere. I might still use CF for the website as well, but I wonder what they class as a "disproportionate percentage of pictures". Commented Sep 7, 2015 at 16:14
  • 1
    I suspect if you're on one of their paid tiers they may be more lenient with this. Were you on a free account by any chance?
    – Simon East
    Commented Nov 20, 2015 at 5:31
  • Is the issue here that you were only routing the subdomain through CF, or that the subdomain was only being used for static file delivery? Is there an issue with routing only one subdomain, if that subdomain happens to be a full web application?
    – BadHorsie
    Commented May 4, 2020 at 15:09
  • @Bad The issue is the subdomain being used for static file delivery. This answer should probably clarify that ‘Cloudflare don't allow this’ is about static file delivery, not subdomains in general.
    – grg
    Commented Mar 27, 2021 at 15:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.