Preface
Since I started getting in touch with Cloudflare (hereinafter referred to as CF) at the end of last year, I have often mentioned in some articles that I wanted to write a series of tutorials on CF features. However, because CF has so many free features, fully understanding a single feature requires constant learning and practical application for a long time. On top of that, constantly coming across new features every now and then leads to another round of learning and practical application, keeping me constantly looping through learning and practical application. Naturally, I haven't had the confidence or the mood to write the tutorial series.
It wasn't until recently that I felt I had explored almost all of CF's commonly used features. Coupled with the fact that there are currently no high-priority individual technical topics I want to write about, I feel I can finally start writing the long-delayed CF tutorial series. This can be considered a summary of my usage of various CF features over the past six months or so, and I will also organize previously scattered articles about CF features into this tutorial series.
However, before starting the official feature usage tutorials, following the convention of general technical solutions, let's first introduce CF company and its related solutions.
Introduction to CF Company and Solutions
Company Profile
Cloudflare is a leading global provider of internet security and performance optimization services. Founded in 2009 and headquartered in San Francisco, California, USA, it protects and accelerates millions of websites, APIs, and internet applications worldwide by providing a range of services, making the internet safer, faster, and more reliable.
Company Scale and Coverage
- Global Network: Cloudflare's global Anycast network covers more than 200 cities across over 100 countries.
- Number of Employees: As of early 2024, Cloudflare has approximately 2,500 employees.
- Customer Base: Cloudflare serves customers of all sizes, from individual websites to large enterprises and government agencies.
Main Products and Solutions
Content Delivery Network (CDN)
Cloudflare's CDN network caches and distributes content through globally distributed servers, significantly reducing page load times and improving user experience.
- Features:
- Static Content Caching: Caches static content of websites (such as images, CSS, JavaScript) to edge nodes.
- Automatic Optimization: Features like file compression, image optimization, and lazy loading to improve performance.
DDoS Protection
Cloudflare provides powerful DDoS protection, capable of detecting and mitigating various types of DDoS attacks to protect websites from large-scale attacks.
- Features:
- Automatic Detection and Mitigation: Real-time monitoring and automatic mitigation of network-layer and application-layer attacks.
- Global Anycast Network: Distributes attack traffic across multiple global nodes to reduce single-point pressure.
DNS Services
Cloudflare provides fast and secure DNS resolution services, ensuring high performance and stability.
- Features:
- Fast Resolution: Provides fast DNS query responses through globally distributed nodes.
- Security: Built-in DDoS protection and DNSSEC support to prevent DNS spoofing and cache poisoning attacks.
Web Application Firewall (WAF)
Cloudflare's WAF filters and blocks malicious requests through a rules engine, protecting websites from common Web application attacks.
- Features:
- Pre-configured Rule Sets: Built-in OWASP Top 10 attack protection rules.
- Custom Rules: Users can create and adjust custom protection rules based on their needs.
SSL/TLS Encryption
Cloudflare provides free and paid SSL/TLS certificates to ensure secure data transmission between clients and servers.
- Features:
- Automated Certificate Management: Automatically generates, renews, and manages SSL/TLS certificates.
- Enforce HTTPS: Automatically redirects all HTTP traffic to HTTPS.
Edge Computing
Cloudflare Workers allow developers to run JavaScript code on global edge nodes, reducing latency and improving performance.
- Features:
- Serverless Computing: Deploy code without managing the underlying infrastructure.
- Fast Response: Reduces round-trip times by processing requests at edge nodes.
Zero Trust Security
Cloudflare provides secure access control solutions based on a Zero Trust model, such as Cloudflare Access and Cloudflare Gateway.
- Features:
- Cloudflare Access: Provides fine-grained access control for applications, supporting multi-factor authentication (MFA).
- Cloudflare Gateway: Protects users from malicious content and website attacks, providing secure internet access.
Advantages of CF Solutions
In fact, there are quite a few foreign companies like CF that provide overall solutions, such as AWS (Amazon Web Services) + CloudFront, Microsoft Azure, GCP (Google Cloud Platform), Imperva, etc. However, compared to these competitors, CF has its own unique advantages:
1. Extensive Global Network Coverage
Cloudflare has a massive Anycast network covering over 200 cities and more than 100 countries. This extensive network coverage enables Cloudflare to provide low-latency and highly reliable services to global users.
In plain English: It has built its own backbone network (a large intranet) globally (except for a few special countries). It can ingest request packets sent from any location (except those few special countries) into its large intranet from the closest access point (edge network) to that sending location, and then route them through the large intranet via the most optimized path to the final destination of the request. As a result, access efficiency is much higher compared to the traditional hop-by-hop routing over the public internet.
2. Integrated Full-Stack Services
Cloudflare provides a comprehensive one-stop service, including CDN, DDoS protection, DNS services, Web Application Firewall (WAF), SSL/TLS encryption, edge computing, and more. This integrated service portfolio allows customers to meet multiple needs on a single platform, simplifying management and operations.
In plain English: It directly integrates all relevant feature configurations into a single user interface, and this interface is constantly adding and integrating new features.
3. Free and Affordable Services
Cloudflare offers both free and paid service options. For small websites and individual users, Cloudflare's free plan is already capable of providing basic security and performance optimization services. For enterprise users, its paid plans are also competitively priced and powerful in features.
In plain English: For the vast majority of individual webmasters, basic features can all be obtained for free (Free plan).
What counts as basic features? Here are a few that I am currently using:
- Unlimited DNS domain hosting (PTR is free to use, as long as you have a static IP address~ Tencent charges 1500/year for 3 PTRs, think about that~)
- Unlimited CDN (actually there is still a limit, for example, if your CDN traffic reaches hundreds of TBs or even PBs~ Last time I saw a guy using CF's free CDN as a cache for an adult website's image hosting, and his account got banned due to excessive traffic~)
- Unlimited COS (which is R2, unlimited storage space, unlimited outbound traffic, but similar to CDN, there should still be an upper limit)
- Free unlimited SSL certificates (probably has a limit too, but I haven't seen anyone mention reaching it)
- Free Email Routing (which lets you receive emails directly using your domain suffix as the email address), allowing you to customize many email prefixes
- Free Web Application Firewall (5-rule limit, which is basically enough for most people, capable of implementing the famous 5-second challenge to block crawlers, hotlink protection, and many other advanced features)
- Transform Rules (10-rule limit, capable of rewriting URLs, modifying request headers, modifying response headers, etc.)
- Redirect Rules (10-rule limit)
- Cache Rules (10-rule limit)
- Page Rules (3-rule limit, capable of implementing many features, but strange, wasn't this deprecated a while ago? How is it active again?)
- Zero Trust network provided by Zero Trust, the Free plan allows adding up to 50 users, which is completely sufficient, providing many applications including the tunnel feature (intranet penetration to directly publish applications). Before June, the WARP enterprise version could also be used, but unfortunately, it is basically useless now.
- Cloudflare Pages (can link with GitHub repositories) static page hosting feature
There are too many, and some features I haven't had the chance to use yet... The above are the most valuable services for individual webmasters. Therefore, some people call Cloudflare a "great philanthropist," and I think it is well-deserved.
4. Innovative Edge Computing
Cloudflare Workers is a powerful edge computing platform that allows developers to run JavaScript code on Cloudflare's edge nodes.
This platform can significantly reduce latency, improving application performance and flexibility. What features can be achieved depends on what JS script is run; there are many worker-based projects on GitHub.
Note: The Free plan offers 100,000 requests per day, which is more than enough for a normal personal blog (except for abnormal traffic, such as attacks). Of course, for some niche features, like a reverse proxy implemented with workers to pull images after Docker Hub was blocked, if too many people use it, the 100,000 quota won't be enough.
5. Powerful DDoS Protection Capabilities
Cloudflare possesses industry-leading DDoS protection technology, capable of automatically detecting and mitigating DDoS attacks of various types and scales. Its global Anycast network design helps distribute attack traffic across multiple nodes, reducing single-point pressure.
The key is, unlimited DDoS attack protection!
Note: I was once hit with 2.2T of traffic in just over 2 hours. If it were with a domestic cloud provider, I estimate the server would have been disconnected from the network, and the CDN traffic would have been exhausted long ago~, saving me a lot of money invisibly.
6. User-Friendly Interface and Management Tools
Cloudflare provides an intuitive and easy-to-use management interface and rich APIs, making it convenient for users to configure and manage their services. Users can easily set and adjust security policies, and monitor traffic and performance data.
Note: I must say, CF's management interface is really well-designed. It's not just a simple combination of all feature configurations; the key is that it intuitively provides the priority order of all features, which I will discuss specifically in the next article.
7. Strong Community and Support
Cloudflare has an active community and comprehensive support documentation to help users solve problems and optimize configurations. Its customer support team is also able to provide professional help and guidance.
8. Continuous Technological Innovation
Cloudflare continuously introduces new products and features to maintain its technological leadership. For example, in addition to the edge computing platform Workers, Cloudflare has also launched Zero Trust security services such as Cloudflare Access and Cloudflare Gateway, as well as the 1.1.1.1 public DNS service (WARP and WARP+), focusing on privacy protection and speed.
Note: For the configuration of WARP+, you can refer to the articleHome Data Center Series: Make Rational Use of Cloudflare WARP to Improve Your Website Access Speed (Desktop Version)和Home Data Center Series: Deploy Cloudflare WARP on Cloud Servers to Improve Network Access Speed (Linux CLI Version)Unfortunately, WARP has basically become unusable since early June, but this was bound to happen sooner or later in China, which is not surprising. The biggest regret is that I only found out about WARP a few months ago, and then kept it as a backup line, barely using it at all!!! I feel like I missed out on hundreds of millions... :(
How CF Benefits Individual Webmasters
Actually, at the beginning, I didn't know any better and honestly used a domestic ICP-filed domain and domestic CDN to build my blog. It was only later that I gradually realized the harshness of the world (see article:Home Data Center Series: Independent Personal Blog Setup and Pitfall Avoidance Guide)
combined with the fact that I was getting in touch with and gradually understanding CF at the time, I made a tough decision to abandon the ICP-filed domain and fully migrate to the current "tangwudi.com".
After using it for more than half a year, I have truly felt the huge benefits CF has brought to me:
DDoS Attack ProtectionHome Data Center Series: Second Attack! Optimization of the internal blog access workflow under the new situation)
Home Data Center Series: Second Attack! Optimization of Internal Blog Access Flow Under the New Situation
WAF Protection
Zero Trust
Relying on Zero Trust's tunnel technology, you can directly penetrate the intranet, allowing home applications to be published directly to the external network in minutes (good news for friends who don't want to file for record, want to build a website, and don't have a public IP address). Even with the default unoptimized configuration, although domestic access is a bit slow, it can still be opened (See article:Home Data Center Series: Using Tunnel Technology to Enable Home Broadband Without Public IP to Leverage Cloudflare for Free to Achieve Rapid Website Setup (Recommended))。
R2 (Object Storage)
Currently, my image hosting is R2. I migrated all image resources from Chevereto to R2. The advantage of this is that there is no need to consider the redundancy of the image hosting (See article:Home Data Center Series: Building an Off-site Disaster Recovery Image Hosting for Chevereto Using rclone and Cloudflare R2), and since the images are not stored locally, one benefit is security (even if the image hosting is attacked, it won't affect the intranet), and the other is being always online. Even if there is a power outage at home and it automatically switches to the redundant WordPress site on the cloud host, it will not affect the normal access to the blog (previously, I also needed to deploy a set of Chevereto on the cloud host and synchronize data between the two sets of Chevereto, which was quite a hassle).
Worker Optimization
Because the Free plan defaults to providing the US West San Jose data center address for users accessing from mainland IP addresses, the default speed for mainland visitors is not fast (even jokingly called negative optimization). However, through a specific worker script, mainland visitors can also achieve the effect of the previous preferred IP (automatically selecting the IP address of the data center closest to the visitor). For personal webmasters with low traffic, the free quota of 100,000 requests per day is basically inexhaustible, so the worker optimization method can greatly improve the access speed of mainland users to the site.
CF Pages
CF's static page hosting function, compared to GitHub Pages, has stronger accessibility in China. Mywww.tangwudi.comnavigation page and Hexo static blog pages are all published by linking GitHub repositories to CF Pages, which is very easy to use (See article:Home Data Center Series: Building a New Home for the www Navigation Page Using GitHub + Cloudflare Pages和Home Data Center Series: Building a Static Blog with Hexo and Deploying It to Cloudflare Pages)。
The above are just the ones I use most frequently. Other relatively less-used features, such as redirection and custom hostnames, are also very important for those who need them. Plus, there are other hidden features provided that most people don't know about, such as multi-site automatic redundancy + load balancing (for multi-site automatic redundancy, see article:Home Data Center Series: Utilizing Cloudflare Tunnel to Achieve Automatic Takeover by Disaster Recovery Site When WordPress Main Site Fails), etc... In short, CF is like a hidden treasure for personal webmasters, waiting for everyone to dig.
Afterword
Currently, Tencent Cloud has also launched an overall solution similar to CF: EdgeOne. The fee is charged based on the number of hosts: 1 hostname is 9.9 RMB/month, which is actually not expensive. However, with my dozens of hostnames, I dare not try it (or I might try it when I'm in the mood and write an article about it). If you are interested, you can also try it. Anyway, at present, it seems that there are relatively few articles writing EdgeOne tutorials on the Internet...