{ # 全局选项 auto_https off admin off log { level info output stdout } } # 如果 DOMAIN 为空,直接走 80 端口 HTTP(自签证书后面再补) # 如果有域名,改用下面的 https 配置块 http://{$DOMAIN:NEWS_DOMAIN_FALLBACK} { # /api/* 直接转发,保留路径(后端 FastAPI 路由就是 /api/v1/*) reverse_proxy /api/* api:8000 { # 把 Caddy 识别的 client IP 写入 X-Forwarded-For(覆盖任何客户端伪造) # 后端 uvicorn --forwarded-allow-ips 信任 docker 网络后会用这个值 header_up X-Forwarded-For {remote_host} } # 其余走前�?SPA reverse_proxy /* frontend:80 encode gzip zstd # 日志 log { output stdout format console } } # 如果有域名,启用自动 HTTPS(取消下面注释,并把上面块注释) # {$DOMAIN} { # reverse_proxy /api/* api:8000 # reverse_proxy /* frontend:80 # encode gzip zstd # }