Files
deploy.stack/honcho/caddy/honcho.conf
T
cnphpbb 2bb7eda17c feat(honcho): 完善公网安全部署与 Agent 拓扑
- 补充 ECS 规格、容量及成本评估文档
- 添加 Caddy 模板、暴露前检查和客户端凭据签发流程
- 收紧监听地址、访问控制、容器资源与日志限制
- 更新部署说明和多客户端共享方案
2026-11-07 17:43:54 +08:00

79 lines
2.9 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ============================================================
# Honcho 公网反向代理(Caddy)
# ============================================================
# 用途:把 honcho-api 的 8000 端口以 HTTPS 暴露到公网
#
# 用法(二选一):
# A) 与 webout 同机 → 合并本文件的站点块到 /data/configs/caddy/web-http.conf
# 并把 reverse_proxy 目标改成 honcho 宿主机内网地址
# B) 独立 Caddy 实例 → 挂载本文件为 Caddyfile
#
# 关键安全点:
# 1. TLS 终止在此,honcho-api 只需监听 127.0.0.1(或内网地址)
# 2. basic_auth 是**第二道锁**,真正的数据隔离靠 honcho 自身的 JWT
# —— Honcho 的 Bearer token 与 basic_auth 都走 Authorization 头,
# Caddy 的 basicauth 会先消费该头,因此**不要**同时用 basicauth
# 和 Honcho Bearer token。二选一:
# · 多客户端 → 关闭 basicauth,用 Honcho scoped JWT
# · 单用户强隔离 → 保留 basicauth,客户端改用 basic 认证头
# 3. 屏蔽 /docs /redoc /openapi.json,避免 API 拓扑对外暴露
# 4. 限流在反向代理层做,Honcho 自身没有 rate limit
#
# 生成 basic_auth 密码哈希:
# docker run --rm caddy:2 caddy hash-password --plaintext '你的密码'
#
# 防火墙:宿主机只放行 80/443 + WireGuard 端口,不要放行 8000/5432/6379
# ============================================================
{
# 全局:日志轮转(Caddy 官方镜像内置)
log {
output file /data/log/caddy-access.log {
roll_size 20MiB
roll_keep 5
}
}
}
https://honcho.6t7.net {
tls moqiruyi@gmail.com
# ---- 屏蔽接口文档与 schema ----
@blocked path /docs /docs/* /redoc /openapi.json /metrics /admin*
respond @blocked 404
# ---- 可选:basic auth 第二道锁 ----
# 启用后客户端需带 Basic 头;若客户端用 Honcho Bearer token,请注释掉本段
# basicauth {
# cnphpbb $2a$14$REPLACE_WITH_HASH_FROM_CADDY_HASH_PASSWORD
# }
# ---- 安全响应头 ----
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains"
X-Content-Type-Options "nosniff"
X-Frame-Options "DENY"
Referrer-Policy "no-referrer"
-Server
}
# ---- 上游 ----
# honcho 宿主机内网地址;API 已按 env.cfg 的 HONCHO_API_BIND 监听
reverse_proxy 10.8.0.9:8000 {
# Caddy 默认会透传客户端传来的 X-Forwarded-For(可伪造),
# 这里显式改写为真实对端 IP,防止 honcho 侧按 IP 做的限制被绕过
header_up X-Real-IP {remote_host}
header_up X-Forwarded-For {remote_host}
header_up X-Forwarded-Proto {scheme}
# 上游健康检查:honcho 挂了自动摘除,避免 502 堆积
health_uri /health
health_interval 30s
health_timeout 5s
# dialectic / dream 是长耗时同步调用,超时放宽
transport http {
read_timeout 300s
write_timeout 300s
dial_timeout 10s
}
}
}