开启防护1
自定义防御规则
在 Security -> WAF 中:
- 点击
Custom rules->Create rule创建自定义规则, 名字随意; - 可以使用
Expression builder或Expression editor来编辑匹配规则; - 匹配动作自行选择
Block(封禁) 或Managed Challenge(质询, 5 秒盾); - 选择放置位置 (可选), 然后保存。
规则总结
常见的蜘蛛爬虫的 User-Agent 有:
|
|
常见扫描路径有:
- 环境变量文件, 如
.env,.env.bak等; WordPress路径, 如wp-admin,wp-content,wp-includes;- 各种
.php文件。
根据以上特征可以编写出 CloudFlare 的规则表达式2:
|
|
直接粘贴到 Expression editor 中保存即可。
如果站点使用了
PHP, 可以添加额外的条件, 将http.request.uri.path contains ".php"替换为(http.request.uri.path contains ".php") and (http.host ne "php.example.com")。
如果用于特殊用途, 建议移除关于Go-http-client的规则。
封禁 Bots
在 Security -> Bots 中:
- 打开
Bot Fight Mode, 但如果域名用于特殊用途, 建议关闭, 不然会影响; - 打开
Block AI Bots
DDoS
在 Security -> DDoS 中:
- 点击
Deploy a DDoS override, 名称随意; Ruleset action和Ruleset sensitivity可以自行选择;- 点击
Save保存。
其他可以做的
在 Security -> Settings 中:
- 调整
Security Level(安全级别); - 更改
Challenge Passage(质询过期时间); - 打开
Browser Integrity Check(浏览器完整性检查)。
在 Network 中, 关闭 Onion Routing。
开启缓存3
在 Cache Rules 中:
- 点击
Create rule创建规则, 名称随意; - 根据网站是否有动态内容来选择
Custom filter expression还是All incoming requests。
一般来说, 网站的静态资源只会存放在某一文件夹, 选择Custom filter expression更好。 Cache eligibility选择Bypass cache将不会缓存,适用于开发模式。
所以选择Eligible for cache。- 其他设置可自行配置。
最常见的配置有Edge TTL(边缘服务器缓存时间),Browser TTL(用户浏览器缓存时间), 打开Cache deception armor和Ignore query string; - 保存部署。
隧道 SaaS 回源
待补充
-
受限于 Free Plan, 不能使用正则表达式匹配, 所以规则表达式比较繁冗 ↩︎