blakejarvis.com
  • blakejarvis.com
  • Home Assistant & Home Automations
    • Setting up FTP with Amcrest Camera
    • Home Assistant Amcrest Video Viewer
  • OSCP
    • External Resources
    • Buffer Overflow Framework
    • OSCP - Things to Try When Stuck
  • Web Server Log Analysis
    • Log Analysis Part 1: Using Fast Reverse Proxy (FRP) to Expose Logging Infrastructure
    • Log Analysis Part 2: Using Logstash’s Grok Filter to Parse Docker Nginx Logs
    • Log Analysis Part 3: Using Greynoise with Logstash
  • Miscellaneous Articles
    • Using Cloudflare Page Rules to Point a Root Domain to a GitBook Site
    • How to Secure the Ghost Blogging Platform
    • An Overview of Apple and Google's Privacy-Preserving Contact Tracing Framework
    • Active Directory Deception Technology
Powered by GitBook
On this page
  • Why Not Double CNAME?
  • DNS Records
  • Cloudflare Page Rules
  1. Miscellaneous Articles

Using Cloudflare Page Rules to Point a Root Domain to a GitBook Site

2021-01-03

PreviousLog Analysis Part 3: Using Greynoise with LogstashNextHow to Secure the Ghost Blogging Platform

Last updated 4 years ago

GitBook only allows the usage of subdomains when pointing to a GitBook site. In the free version of GitBook, this can't be changed but an HTTP redirect via a Cloudflare page rule is a cheap, fast, and easy way to send users from a root domain to a subdomain where a GitBook site is hosted.

Example: blakejarvis.com -> www.blakejarvis.com (GitBook site)

Why Not Double CNAME?

Using a CNAME pointer to redirect blakejarvis.com to www.blakejarvis.com via DNS would make the most sense, but Cloudflare doesn't allow double CNAMEs within the Cloudflare network. Instead, a Cloudflare page rule will serve an HTTP 301 redirect to send all users to www.blakejarvis.com where the GitBook Site is hosted.

DNS Records

Add a CNAME DNS entry in the domain's DNS zone to point www.blakejarvis.com to hosting.gitbook.io. This is required by GitBook.

Add a 'dummy' DNS a record for the root site blakejarvis.com to point anywhere. In this case, Cloudflare's 1.1.1.1 resolver is used.

Cloudflare Page Rules

Create a page rule to redirect all traffic to blakejarvis.com to www.blakejarvis.com via a 301 HTTP redirect. Any 301 redirect implementation will work (e.g. PHP on Apache), but serving this rule at the Cloudflare edge will be the fastest.