Files
pangolin/infra/domains/cdn/terraform/waf.tf
T
wangjia 7d89ec9d91 feat(infra/domains): 域名池 + CDN 前置 + 签名端点分发 (tsk_NU9JuUweHWMt)
- domains.md: 四组域名隔离登记 + 冷备池 ≥5 + 启用流程(不含身份信息)
- cdn/terraform: Cloudflare 配置即代码(WAF/bot/速率限制/代理DNS/回源鉴权注入)+ 30min 重放 Runbook
- server/internal/originauth: 回源鉴权中间件,非 CDN 网段或鉴权头不符一律 403,支持双值轮换
- tools/endpoint-signer: 离线 Ed25519 签名 CLI(端点 + 公告文档,单调版本防回滚,key_id 双公钥轮换)
- tools/publish-mirrors: ≥3 镜像发布 + hash 一致性校验 + 故障转移取回
- CLIENT-CONTRACT.md: schema/验签/防回滚/合并/兜底链/channel 客户端契约
- 出站独立出口要求写入部署文档;私钥/token/身份信息一律不入库

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-13 14:21:55 +08:00

68 lines
1.9 KiB
Terraform

# WAF managed rulesets (doc/05 §2 WAF 全开).
resource "cloudflare_ruleset" "waf_managed" {
zone_id = var.zone_id
name = "pangolin-waf-managed"
kind = "zone"
phase = "http_request_firewall_managed"
rules {
action = "execute"
description = "Cloudflare Managed Ruleset"
enabled = true
expression = "true"
action_parameters {
# Cloudflare Managed Ruleset (stable well-known ID).
id = "efb7b8c949ac4650a09736fc376e9aee"
}
}
rules {
action = "execute"
description = "Cloudflare OWASP Core Ruleset"
enabled = true
expression = "true"
action_parameters {
# OWASP Core Ruleset (stable well-known ID).
id = "4814384a9e5d4991b9815dcfc25d2f1f"
}
}
}
# Rate limiting (doc/05 §2 速率限制全开). Per-IP budget on the API surface.
resource "cloudflare_ruleset" "rate_limit" {
zone_id = var.zone_id
name = "pangolin-rate-limit"
kind = "zone"
phase = "http_ratelimit"
rules {
action = "block"
description = "Per-IP rate limit on /v1/*"
enabled = true
expression = "(starts_with(http.request.uri.path, \"/v1/\"))"
ratelimit {
characteristics = ["ip.src", "cf.colo.id"]
period = 60
requests_per_period = var.rate_limit_requests_per_minute
mitigation_timeout = var.rate_limit_mitigation_seconds
}
}
}
# Bot management (doc/05 §2 bot 管理全开). Requires Bot Management / Super Bot
# Fight Mode on the plan; toggle with enable_bot_management.
resource "cloudflare_bot_management" "this" {
count = var.enable_bot_management ? 1 : 0
zone_id = var.zone_id
enable_js = true
sbfm_definitely_automated = "block"
sbfm_likely_automated = "managed_challenge"
sbfm_verified_bots = "allow"
sbfm_static_resource_protection = false
optimize_wordpress = false
}