一个计算机技术爱好者与学习者

0%

Cloudflare配置概述

1. 添加域名

  1. Create a Cloudflare account and add your domain.

  2. Choose Plan.

  3. Change your nameservers.

2. 快速配置

快速配置地址:
https://dash.cloudflare.com/<xxx>/voidking.com/recommendations
其中 <xxx> 要改成Cloudflare自动生成的随机字符串。

  1. 提高安全性,自动HTTPS重写,始终使用HTTPS
  2. 优化性能,Brotli压缩
  3. 摘要

3. DNS记录

Cloudflare的DNS记录比较特殊,它支持两种解析方式:

  • 仅DNS:和其他域名服务器一样,域名解析到指定的地址;
  • 代理:通过Cloudflare代理真实服务器的流量,也就是说域名解析到的地址是代理地址,真实地址会被隐藏。

解析方式是代理的情况下,就可以防DDoS了,因为代理服务器是防DDoS的,黑客攻击不到我们的真实地址。

4. CloudFlare for SaaS配置

4.1. 添加域名

  1. Create a Cloudflare account and add your domain.

  2. For your Plan, choose Business or Enterprise.

  3. Add your domain to Cloudflare. You should land on the Overview page.

  4. Ignore the instructions to change your nameservers.

  5. For Advanced Actions, click Convert to CNAME DNS Setup.

4.2. 验证域名

Once you add your domain to Cloudflare, add the Verification TXT Record at your authoritative DNS provider. Cloudflare will verify the TXT record and send a confirmation email. This can take up to a few hours.

4.3. 添加解析

  1. In Cloudflare, add an A, AAAA, or CNAME record.

  2. At your authoritative DNS provider:

a. Remove any existing A, AAAA, or CNAME records on the hostname you want to proxy to Cloudflare.

b. Add a CNAME record for {your-hostname}.cdn.cloudflare.net.

c. Repeat this process for each subdomain proxied to Cloudflare.

5. CloudFlare的坑

使用CloudFlare作为代理后,真实后端响应时间必须在100s以内,否则会报错524。
解决办法是升级企业版,详情参考Troubleshooting Cloudflare 5XX errors – Cloudflare Help Center

  • 本文作者: 好好学习的郝
  • 原文链接: https://www.voidking.com/dev-cloudflare-config/
  • 版权声明: 本文采用 BY-NC-SA 许可协议,转载请注明出处!源站会即时更新知识点并修正错误,欢迎访问~
  • 微信公众号同步更新,欢迎关注~