# ==================== DesignerCEP Caddy 配置 ==================== # # 用途: # - app.aidg168.uk → 前端应用(静态文件) # - backend.aidg168.uk → 后端 API(反向代理到 FastAPI) # # 部署位置:/etc/caddy/Caddyfile { # 邮箱(用于 HTTPS 证书) email admin@aidg168.uk # 使用 Cloudflare 橙云代理,关闭自动 HTTPS auto_https off } # ==================== 前端应用 ==================== http://app.aidg168.uk, https://app.aidg168.uk { # 静态文件根目录(已修复路径) root * /var/www/app # SPA 路由支持(所有请求返回 index.html) try_files {path} /index.html # 提供静态文件 file_server # ========== 缓存策略 ========== # HTML 不缓存 @html path *.html header @html Cache-Control "no-cache, no-store, must-revalidate" # JS/CSS 长期缓存 @assets path *.js *.css *.woff *.woff2 header @assets Cache-Control "public, max-age=31536000, immutable" # 图片缓存 @images path *.png *.jpg *.jpeg *.gif *.svg *.ico header @images Cache-Control "public, max-age=2592000" # ========== 安全头 ========== header { # 允许 CEP 插件通过 iframe 嵌入 # 注释掉 X-Frame-Options 以支持 Photoshop 插件 # X-Frame-Options "SAMEORIGIN" X-Content-Type-Options "nosniff" X-XSS-Protection "1; mode=block" -Server } # ========== 压缩 ========== encode gzip # ========== 日志 ========== log { output file /var/log/caddy/app.log { roll_size 50mb roll_keep 5 } } } # ==================== 后端 API ==================== http://backend.aidg168.uk, https://backend.aidg168.uk { # 反向代理到 Docker 容器(localhost:8000) # Caddy 在宿主机运行,需要通过 localhost 访问 Docker 容器 reverse_proxy localhost:8000 { header_up X-Real-IP {remote_host} } encode gzip log { output file /var/log/caddy/backend.log { roll_size 50mb roll_keep 5 } } } # ==================== 主域名重定向 ==================== http://aidg168.uk, http://www.aidg168.uk, https://aidg168.uk, https://www.aidg168.uk { redir https://app.aidg168.uk{uri} permanent }