Configure Custom Domain and Sub-domain with GitHub Pages in Cloudflare

Mastering DNS Records, CNAME Routing, & SSL Encryption...

Category: DNS Management, Cloud Infrastructure & Web Hosting (Comprehensive Pillar Document)

The Comprehensive Guide to Mapping Custom Domains and Sub-domains to GitHub Pages via Cloudflare

Published by RelMusic Cloud Infrastructure Division | Production Ready for 2026 Standards

Configure Custom Domain and Sub-domain with GitHub Pages in Cloudflare

Hosting static websites, documentation portals, or enterprise web ecosystems on GitHub Pages provides unmatched reliability and seamless version control. However, using the default username.github.io URL structure lacks professional branding. Integrating a custom apex domain (e.g., relmusic.com) or a dedicated sub-domain (e.g., blog.relmusic.com) through Cloudflare supercharges your web property with lightning-fast CDN caching, robust DDoS protection, and automated SSL/TLS encryption.

This technical guide details the precise end-to-end configuration required to bridge GitHub Pages with Cloudflare DNS management.

1. Understanding GitHub Pages DNS Requirements

Before configuring Cloudflare, it is crucial to understand how GitHub Pages recognizes custom domains. GitHub requires either an apex domain redirect or a direct CNAME pointer matching your GitHub Pages username repository.

Apex Domains vs. Sub-domains

2. Step-by-Step Configuration in Cloudflare Dashboard

Follow these steps to route your domain traffic correctly through Cloudflare DNS:

Step 1: Add Your Domain to Cloudflare

Log in to your Cloudflare account, click Add a Site, enter your domain name, and select a free or paid plan. Update your domain registrar's nameservers to point to the provided Cloudflare nameservers.

Step 2: Configure DNS Records for Sub-domains

For a sub-domain such as blog.relmusic.com, add a CNAME record in the Cloudflare DNS manager:

Step 3: Configure DNS Records for Apex Domains

If you are mapping the root domain (relmusic.com), set up the four GitHub IP A records:

Type Name IPv4 Target Address Proxy Status
A@185.199.108.153Proxied / DNS Only
A@185.199.109.153Proxied / DNS Only
A@185.199.110.153Proxied / DNS Only
A@185.199.111.153Proxied / DNS Only

3. Establishing the CNAME File in Your GitHub Repository

GitHub needs verification that you own the custom domain. In your GitHub repository root directory, create a file named CNAME (without any file extension) containing only your custom domain name (e.g., blog.relmusic.com or relmusic.com).

Once pushed to your repository, navigate to your GitHub repository settings under Pages, and enter your custom domain into the designated custom domain field.

4. Optimizing SSL/TLS Settings in Cloudflare

To avoid SSL certificate errors (such as ERR_CERT_COMMON_NAME_INVALID) between Cloudflare and GitHub Pages:

External Authoritative References

Internal Pillar Links


Frequently Asked Questions (FAQ)

1. Why is my GitHub Pages custom domain showing a 404 error?

A 404 error usually occurs if the CNAME file is missing from your repository root or if DNS propagation has not fully completed across global nameservers.

2. Should I use 'Proxied' or 'DNS Only' mode in Cloudflare for GitHub Pages?

During initial setup and GitHub's SSL certificate provisioning, it is recommended to set records to 'DNS Only'. Once verified and active, you can switch them to 'Proxied' to leverage Cloudflare's CDN and security features.

3. What is the purpose of the CNAME file in a GitHub repository?

The CNAME file informs GitHub Pages which custom domain or sub-domain should be bound to your repository's public web traffic.

4. How long does DNS propagation take after configuring Cloudflare?

DNS propagation typically takes anywhere from a few minutes up to 24 hours globally, though Cloudflare updates usually propagate almost instantly within minutes.

5. How do I fix the 'Domain already taken' error on GitHub?

This error occurs when another public GitHub repository is already configured with your custom domain. You must locate that repository and remove the custom domain setting before claiming it on your current repository.

6. What SSL/TLS setting should I select in Cloudflare for GitHub Pages?

Select the 'Full' or 'Full (strict)' encryption setting to ensure secure end-to-end communication between Cloudflare edge servers and GitHub Pages.

7. Can I host multiple sub-domains on GitHub Pages from different repositories?

Yes, you can configure unique sub-domains (e.g., app.relmusic.com and blog.relmusic.com) by creating separate CNAME records pointing to their respective GitHub repository pages.

8. How does RelMusic utilize Cloudflare and GitHub Pages?

RelMusic leverages GitHub Pages for reliable static web delivery paired with Cloudflare CDN caching and custom routing to ensure high availability and rapid asset loading worldwide.


Image Resource Repository

cube.png ai.jpeg relmusic.jpg relmusic.png voice.png r.jpg ip.png search.png tts.png calendar.jpeg

Curated Media Showcase

DNS Routing: Visualizing global edge traffic distribution.

SSL Handshake: Secure certificate verification stream.


Cloud & Hosting Utilities Guide

Explore RelMusic embedded web utilities and connectivity modules:


Contact Form & Social Sharing

Share this guide:

Facebook Twitter / X WhatsApp

Conclusion

Configuring custom domains and sub-domains for GitHub Pages using Cloudflare combines the robust version control of GitHub with enterprise-grade CDN caching, DDoS defense, and seamless SSL encryption. By following this technical blueprint, you ensure your web ecosystem remains secure, fast, and professionally branded.