Set Up CloudFlare Workers to Use Your Own Domain

CloudFlare is the world’s leading provider of CDN solutions and domain name registration resolution solutions, and Workers is a serverless application based on its powerful CDN global cloud network.

Having previously shared the List of Google Drive and OneDrive File Lists on platforms such as CloudFlare Workers, the long domain name created by this method is not suitable for sharing, so consider using your own domain name to access it.*.*.workers.dev Search edgy, about this piece is basically a piece of a strip, written unclear, novice snobs is difficult to start, so here to make a record for reference.

Principle

As long as the cloudFlare CDN itself supports a domain name that can be used as a CloudFlare Workers domain name, it is important to note that the domain name needs to be hosted on CloudFlare, i.e. the name service of the domain name must be CloudFlare.

The reason you can’t take a custom domain name when you use other tutorials to set up a custom domain name is that the custom domain name isn’t hosted on CloudFlare, and the blogger spending a lot of time here.

Steps

The main two steps are to add a custom domain name to the CloudFlare network and the other to associate the domain name to the Worker sub-domain name. There are no strict requirements for the order of these two steps.

Custom domain names

As mentioned earlier, domain names, such as itprosec.commust be hosted on CloudFlare, and other DNS registrars cannot access through CNAME, resulting in various odd-shaped errors.

Domain hosting is not difficult, will use CloudFlare will, no longer repeat, according to the page prompt scant can be:

添加域名

After the domain name is successfully added, a new DNS record is added,Name is the subdomain to be customized (such as  worker1.itprosec.com  is odthe value does not matter, the key is to enable the agentProxied

添加记录

Associated domain names

After you create Workers switch to your domain's Workers tab for the domain name (note that the domain name is here, where in Workers you won't find a place to associate it with your domain and then add the association to Add route

添加路由

Route fills in the 子域名 , s/ /* worker1.itprosec.com /) ,Worker selects Workerwho needs to customize the domain name access , note s 选择 ” , so you need to create a Worker and then associate , to represent access to the Worker service through this custom domain name: worker1.itprosec.com/*

关联路由

When you’re done, you can access the Worker service through a custom domain name, such as https://worker1.itprosec.com

Summarize

To summarize, two key points:

  • The domain name must be hosted on CloudFlare;
  • The worker needs to be added as a route association after it is created;

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.