Skip to content

Accelerating Workers & Pages Projects with Preferred Domains

Accelerating Workers & Pages Projects with Preferred Domains

Section titled “Accelerating Workers & Pages Projects with Preferred Domains”

While there are many tutorials online about setting up preferred domains for websites using Cloudflare CDN, there are few specifically addressing Workers and Pages projects. This leaves many beginners only able to use Cloudflare’s assigned IPs for CDN acceleration. This tutorial will teach you how to set up preferred domains for Workers and Pages projects to make your projects run faster.

First, you need to determine which preferred domain you will use. You can use your own preferred domain or one maintained by the community.

  • The preferred domain used in this tutorial is visa.cn
  • You need a domain that has been transferred to Cloudflare (free domains with two-way resolution cannot be used), example: 0163.eu.org

Using Preferred Domains for Workers Projects

Section titled “Using Preferred Domains for Workers Projects”

The custom domain example used in this tutorial for the Worker is todo.0163.eu.org.

  1. Add CNAME Resolution Record

    Add a CNAME-type resolution record for your domain todo.0163.eu.org:

    • Name: Enter your desired custom domain, such as todo;
    • Target: Enter your preferred domain, such as visa.cn;

    chrome_bMEzfu5Tfg.webp

  2. Add Route for Workers Project

    Go to Workers Routes in the left menu bar, click Add Route:

    chrome_poNZDF1Tjm.webp

    • Route: Enter your final custom domain in this format:
      todo.0163.eu.org/*
    • Worker: Select the corresponding project name, click Save.

    chrome_x3OMWGsUbb.webp

Before and After Comparison for Workers Project

Section titled “Before and After Comparison for Workers Project”
todo.0163.eu.org_before.webp

Using Preferred Domains for Pages Projects

Section titled “Using Preferred Domains for Pages Projects”

The custom domain example used in this tutorial for Pages is drive.0163.eu.org.

  1. Add Custom Domain to Pages Project First, add a custom domain to your Pages project, note down the CNAME target domain drive-ba3.pages.dev, and wait for the custom domain to take effect.

    chrome_boNcUC6QwG.webp

  2. Use Huawei Cloud International - DNS Service

    The international version doesn’t require real-name verification. If you’re frequently redirected to the domestic version during registration, please enable global proxy mode to register.

    chrome_9ubxNr42qX.webp

    Set security phone (can be skipped)

    83a19bee9f105b7cd5fdf.webp

    Activate Huawei Cloud

    4182536ad257fbde94a3b.webp

    Being redirected to the “Complete Information” page means registration is complete, you can ignore the binding prompts.

    08291704cc96a8f288e79.webp

  3. Add Custom Domain to DNS Service

    Click to go to DNS Service, then click Public Domain

    a4b2b5f8579615fbb122a.webp

    Click Create Public Domain in the top right corner

    f27c15cb84011622a0110.webp

    Enter the Pages custom domain drive.0163.eu.org that needs optimization, then click OK

    chrome_5LN7fqBrk7.webp

    Click Manage Resolution for drive.0163.eu.org

    chrome_8wrZXWaKS9.webp

    After entering Manage Resolution, click Add Record Set in the top left corner

    Add a new CNAME Record

    • Record Type: CNAME - Point domain to another domain
    • Host Record: Leave empty
    • Line Type: Default
    • Record Value: Pages project assigned domain drive-ba3.pages.dev

    chrome_qujrfVr0pX.webp

    Add another CNAME Record

    • Record Type: CNAME - Point domain to another domain
    • Host Record: Leave empty
    • Line Type: Geographic Resolution > Mainland China
    • Record Value: Preferred domain visa.cn

    chrome_rxryZLPLl6.webp

    Hover over the first NS record and copy all four NS record values to save.

    chrome_39O7dqVxJm.webp

    ns1.huaweicloud-dns.com.
    ns1.huaweicloud-dns.cn.
    ns1.huaweicloud-dns.net.
    ns1.huaweicloud-dns.org.
  4. Set Custom Domain NS Records to Huawei Cloud NS Records

    Add four Huawei Cloud NS type resolution records for your domain drive.0163.eu.org to take effect.

    chrome_7PJcOqYF9j.webp

    chrome_ixlVbB8j5A.webp

Before and After Comparison for Pages Project

Section titled “Before and After Comparison for Pages Project”
drive.0163.eu.org_before.webp