Cloudflare services are enabled for a given domain name and once activated can also be applied for any of its subdomains.
Before you can use Cloudflare for a subdomain, you would have to enable the service for your main domain. You can find out how to enable Cloudflare for your domain in our Cloudflare tutorial.
Once the service is active, to also use it with a subdomain, follow these steps:
1. Go to your cPanel, click on the Cloudflare icon and then the Manage button next to your domain.
2. The first tab on the next page, titled Subdomain, is where you can find a list of the existing subdomains for your domain and whether Cloudflare is active for any of them. Next to each subdomain there will also be an Activate button to activate the service. Click it.
3. In the Points To column you will now have a hostname like:
www.sub.domain.com.cdn.cloudflare.com
where sub.domain.com is your subdomain. Copy that hostname to your clipboard.
4. Go to your cPanel -> Advanced DNS Zone Editor. If you have more than one domain names associated with the account there will be a drop-down menu. Choose the domain Cloudflare has been activated for, in our example that would be domain.com.
5. Once the zone is loaded find the records for subdomain sub.domain.com - you should see one entry for an A type record and, if you have SPF enabled, one for TXT type record. If you see a TXT record, delete it by clicking Delete next to it and then click on Edit next to the A type record.
6. Change the type from A to CNAME and paste the Cloudflare hostname you copied in step 3 in the Address field.
7. Click Edit Record to save the change and allow a few hours for DNS propagation. That's it, you have activated Cloudflare for your subdomain.
There is also no problem to use Cloudflare PLUS with a subdomain. Just like the Free version of the service, Cloudflare PLUS is enabled and works with a specific domain, and can also be applied for any of its subdomains. When Cloudflare PLUS is activated for your domain, there are no additional fees required to also use it with any of its subdomains. Cloudflare PLUS can be activated for a subdomain in the same way as with the Free service.