Cloudflare's free serverless deployment solution
Introduction
Cloudflare Pages
Cloudflare Pages 是一个用于部署静态网站和前端应用的平台。它专注于提供快速、安全的全球静态内容交付。你可以将你的代码存储在 Git 仓库(如 GitHub、GitLab、Bitbucket)中,Pages 会自动构建和部署你的应用。
核心特点:
自动构建与部署: Pages 能够自动检测 Git 仓库的变化,并根据你的配置构建和部署你的静态站点。
全局 CDN: 利用 Cloudflare 的全球 CDN 网络,确保你的站点在全球范围内快速加载。
免费套餐: Cloudflare Pages 提供了一个慷慨的免费套餐,非常适合个人项目和小型网站。
自定义域名: 支持自定义域名,你可以将 Pages 部署的站点绑定到你自己的域名上。
适用场景:
个人博客
文档站点
作品集网站
优势:
易于使用: 非常容易上手,配置简单。
高性能: 利用 Cloudflare 的 CDN 网络,提供出色的性能。
自动化: 自动构建和部署,节省时间和精力。
免费套餐: 免费套餐适合大多数小型项目。
与 Git 集成: 无缝集成 Git 仓库,方便代码管理。
Cloudflare Workers
Cloudflare Workers 是一个无服务器计算平台,允许你在 Cloudflare 的全球网络边缘运行代码。你可以在靠近你的用户的地方运行 JavaScript、WebAssembly 和其他代码,从而降低延迟并提高性能。
核心特点:
边缘计算: 代码在全球 Cloudflare 数据中心运行,靠近用户,降低延迟。
无服务器: 无需管理服务器,按需付费。
支持多种语言: 支持 JavaScript、WebAssembly (WASM) 和其他语言。
全局变量和绑定: 可以绑定到 Cloudflare 的其他服务,如 Workers KV (键值存储)、D1数据库。
中间件: 可以用作 HTTP 请求和响应的中间件,修改请求或响应的内容。
WebSocket 支持: 支持 WebSocket,可以构建实时应用。
流处理: 能够处理大型数据流。
适用场景:
API 网关
A/B 测试
身份验证
动态内容处理
WebSocket 应用
URL 重定向
安全策略执行
请求重写和路由
优势:
高性能: 边缘计算降低延迟。
可扩展性: 自动扩展,无需担心服务器容量。
灵活性: 可以构建各种应用程序,从简单的 HTTP 中间件到复杂的 API 网关。
全球网络: 利用 Cloudflare 的全球网络,覆盖全球用户。
低成本: 按需付费,节省服务器成本。
Pages versus Workers:

In many cases, Pages and Workers can be used together. For example, you can use Pages to deploy your frontend application, and then use Workers to handle API requests or implement other server-side logic. This combination allows you to leverage the strengths of both technologies to build high-performance, scalable applications.
Limitations of free packages

Despite these limitations, free plans are sufficient for small projects, personal websites, and learning purposes.
Cloudflare account
If you don't already have a Cloudflare account, please register for a free one first:
This part is quite simple and basic, so I won't go into detail. You can register using an email address. Cloudflare doesn't handle email very strictly; you can also set up your own email server as long as it can receive verification codes.
https://dash.cloudflare.com/sign-up
Steps for deploying Pages
点击左侧的 Workers 和 Pages

Click Create

Click on Pages

Choose a creation method. If your project already exists on GitHub or you want to host it there, or if you need to collaborate with others, choose the first option. If your project is a personal one, we recommend choosing the second option.
Here, I'm using direct upload for demonstration purposes.
Here, you need to enter the project name and click "Create Project".
Please note: If you have a domain, enter it here; otherwise, the project name will determine the free domain that is generated later. The generated domain will be: project\_name + (random string) + .pages.dev. After entering, please check to see if your project name and another one are the same. If they are, Cloudflare will automatically add a random string, which cannot be removed unless you change the project name.

Project names that conflict with those of other projects:

Ensure that your project name does not duplicate any existing projects.

Click "Choose from computer".

At this point, there are two options available, and both work. I will demonstrate using the compressed file that I upload.
Once all files have been successfully uploaded, click "Deploy Site".

Click the link to access the website. The initial deployment may take some time.

Update the project. Continue clicking on "Workers" and "Pages" on the left side.
Enter your project.

Click Create Deployment

At this point, the current page and the page from step 7 are identical.

Bind a personal domain (optional)
Return to your project
Click "Custom Domain" and then click "Set Custom Domain".

Enter your custom domain (the domain name does not need to be hosted on Cloudflare).

If your domain name is already hosted on Cloudflare, simply confirm it and wait for about 10 minutes, and your custom domain will be set up.

If your domain name is not hosted on Cloudflare, you will need to configure the CNAME yourself.

Click "Start" to begin CMANE configuration.

Add this CNAME setting to your DNS provider's settings, and the DNS records will be updated automatically. You don't need to click on any button.
Regarding domain names, if you're looking to purchase a low-cost domain name, I recommend buying a .xyz domain from spaceship. The price is very low, less than 5 yuan (RMB), and it's not a scam.
https://spaceship.com
Enter a 6-digit number that you can remember, plus ".xyz"
Due to fluctuations in exchange rates, prices here may vary slightly.

My bill:

Summary:
This document provides a good introduction to Cloudflare Pages and Workers, along with instructions for deploying Pages. The document's structure is clear, and it compares the features, advantages, and use cases of Pages and Workers. The screenshots showing the deployment steps for Pages are clear and detailed, providing users with excellent guidance. The domain name recommendations are also practical, considering the need for low-cost solutions.
Because the deployment steps for Workers are significantly more complex than those for Pages. The deployment steps for Workers will be described in a later article (which has not yet been written).
Concluding Remarks
This article was shared by "吾爱破解" author bob666zxj. The main reason I found it useful is that it provides a good overview of the rules, especially for those in the radio community who may sometimes make mistakes due to their expertise. It's helpful because it covers both aspects. I hope this article will be helpful to everyone.