Cloudflare offers a powerful suite of services to protect and enhance your website. Once Cloudflare is activated for your main domain, you can extend its benefits to any subdomains associated with it. This guide will walk you through the steps to enable Cloudflare for a subdomain, ensuring it’s properly configured and optimized.
Step 1: Enable Cloudflare for Your Main Domain
Before you can activate Cloudflare on a subdomain, ensure that Cloudflare is already set up for your main domain. If not, start by adding your primary domain to Cloudflare:
- Log in to Your Cloudflare Account: Visit the Cloudflare website and sign in.
- Add Your Main Domain: Click “Add Site,” enter your domain name, and follow the prompts to update your DNS settings and nameservers to Cloudflare’s.
Step 2: Create the Subdomain via cPanel
If your subdomain isn’t created yet, follow these steps to set it up using cPanel:
- Access cPanel: Log in to your hosting account’s cPanel.
- Navigate to the Domains Section: Locate the ‘DOMAINS’ section and click on the “Domains” icon.
- Create a New Subdomain:
- Click “Create A New Domain.”
- Enter your desired subdomain (e.g.,
subdomain.yourdomain.com
). - Leave the “Share document root” option unchecked to use a separate document root.
- Choose a directory under your account’s home directory to store the subdomain’s files.
- Submit: Click the “Submit” button to create your subdomain.
Step 3: Configure DNS Settings in Cloudflare
Now that your subdomain is created, you’ll need to configure its DNS settings within Cloudflare:
- Log in to Cloudflare: Access your Cloudflare account.
- Navigate to DNS Settings:
- Select your main domain from the dashboard.
- Click on the “DNS” tab to access DNS management.
- Add a DNS Record for the Subdomain:
- Look for an existing DNS record for your subdomain (it might have been automatically added when you created the subdomain in cPanel).
- If the record doesn’t exist, add a new one:
- Choose the record type (usually “A” or “CNAME”).
- For an “A” record, enter the subdomain in the “Name” field and your server’s IP address in the “IPv4 address” field.
- For a “CNAME” record, enter the subdomain in the “Name” field and the canonical domain name it points to in the “Domain name” field.
- Ensure the cloud icon next to the record is orange, indicating that Cloudflare’s proxy is enabled. Click it to toggle if needed.
Step 4: Configure SSL/TLS Settings (Optional but Recommended)
Securing your subdomain with SSL/TLS is crucial:
- Go to the “SSL/TLS” Tab:
- Choose the appropriate SSL mode: Flexible, Full, or Full (strict).
- “Full (strict)” is recommended if your server has a valid SSL certificate.
Step 5: Set Up Page Rules for Subdomains (Optional)
You can create specific rules to control how Cloudflare interacts with your subdomain:
- Go to the “Page Rules” Tab:
- Click “Create Page Rule.”
- Enter the URL pattern for your subdomain (e.g.,
subdomain.yourdomain.com/*
). - Configure settings like caching, SSL, etc., based on your needs.
Step 6: Test Your Configuration
After completing the setup:
- Wait for DNS Propagation: DNS changes can take some time to propagate globally.
- Verify Your Subdomain: Visit your subdomain in a web browser to ensure it’s resolving correctly and is being proxied through Cloudflare.
By following these steps, you can successfully activate Cloudflare on subdomain created through cPanel. This ensures your subdomain benefits from Cloudflare’s performance enhancements and security features. Should you encounter any issues, don’t hesitate to reach out to us