Files
agento3/Caddyfile

124 lines
2.4 KiB
Caddyfile
Raw Normal View History

# AO3 Mirror - Caddy 配置
# 前端负载均衡 + TLS 终止 + Cloudflare CDN 集成
agento3.miscs.dev {
# 全局头
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains"
X-Content-Type-Options "nosniff"
X-Frame-Options "SAMEORIGIN"
X-XSS-Protection "1; mode=block"
Referrer-Policy "strict-origin-when-cross-origin"
-Server
-X-Powered-By
}
# 日志
log {
output file /var/log/ao3-mirror/access.log {
roll_size 100mb
roll_keep 7
roll_keep_for 720h
}
format json
}
# 压缩
encode gzip
# 后端负载均衡 (轮询) - 2 workers on 2-core machine
reverse_proxy 127.0.0.1:8081 127.0.0.1:8082 {
lb_policy round_robin
health_uri /health
health_interval 10s
health_timeout 5s
# 超时配置
transport http {
read_timeout 30s
write_timeout 30s
dial_timeout 5s
}
header_up X-Forwarded-For {remote_host}
header_up X-Forwarded-Proto {scheme}
header_up X-Real-IP {remote_host}
}
}
# 统计子域名 - 监控面板和指标
stats.agento3.miscs.dev {
# 安全头
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains"
X-Content-Type-Options "nosniff"
X-Frame-Options "SAMEORIGIN"
Referrer-Policy "strict-origin-when-cross-origin"
-Server
-X-Powered-By
}
# 日志
log {
output file /var/log/ao3-mirror/stats-access.log {
roll_size 100mb
roll_keep 7
roll_keep_for 720h
}
format json
}
# 压缩
encode gzip
# 路由规则 - 只暴露 /stats 和 /metrics
route {
# /stats 页面 - 代理到后端
reverse_proxy /stats* 127.0.0.1:8081 127.0.0.1:8082 {
lb_policy round_robin
health_uri /health
health_interval 10s
health_timeout 5s
transport http {
read_timeout 30s
write_timeout 30s
dial_timeout 5s
}
header_up X-Forwarded-For {remote_host}
header_up X-Forwarded-Proto {scheme}
header_up X-Real-IP {remote_host}
}
# /metrics 指标 - 代理到后端
reverse_proxy /metrics* 127.0.0.1:8081 127.0.0.1:8082 {
lb_policy round_robin
health_uri /health
health_interval 10s
health_timeout 5s
transport http {
read_timeout 30s
write_timeout 30s
dial_timeout 5s
}
header_up X-Forwarded-For {remote_host}
header_up X-Forwarded-Proto {scheme}
header_up X-Real-IP {remote_host}
}
# 健康检查
respond /health* 200 {
body `{"status":"ok"}`
}
# 其他路径返回 404
respond * 404
}
}