Caddyfile 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # 反向代理配置
  2. #
  3. # Reverse proxy configuration
  4. #
  5. # DSH 反向代理:纯反代(无 basic auth,鉴权在 dsh 自身完成)
  6. #
  7. # DSH reverse proxy: pure proxy (no basic auth; authentication is enforced by dsh itself)
  8. #
  9. # 0.1.2-rc.1 起鉴权迁回 dsh:浏览器需先用 `?token=<一次性>` 命中 dsh,由 dsh 派发持久 cookie;
  10. # 旧版本(≤0.1.1-rc.2)的 caddy basic auth 与 dsh 0.1.2-rc.1 的 token/cookie 鉴权重复,
  11. # 保留 caddy basic_auth 会拦截首次访问根路径的浏览器跳转(用户根本看不到 dsh 的 token URL)。
  12. # 因此取消 basic auth;DSH_AUTH_USER/PASSWORD/HASH 现在不再被 caddy 使用,但 .env 仍保留以
  13. # 兼容未来回退到旧版本
  14. #
  15. # Since 0.1.2-rc.1, authentication moved into dsh: the browser must first hit dsh with
  16. # `?token=<one-time>` and receive a persistent cookie. The old caddy basic_auth (≤0.1.1-rc.2)
  17. # now duplicates dsh 0.1.2-rc.1's token/cookie auth and intercepts the browser's first
  18. # root-path redirect, hiding dsh's token URL from the user. Drop basic_auth here;
  19. # DSH_AUTH_USER/PASSWORD/HASH are unused by caddy now but kept in .env for forward/back compat
  20. #
  21. # 注意:
  22. # - 容器内必须监听 0.0.0.0(Docker 端口映射 DNAT 到容器 eth0,bind loopback 会拒接映射流量)
  23. # - DSH 0.1.2-rc.1 的 web 模式强制 loopback bind(上游显式拒绝 --host 0.0.0.0),
  24. # 反代是当前唯一让外部访问到 3080 的方式
  25. # - DSH 特权 API(settings.*/credentials.*)只接受 loopback 来源(防 DNS rebinding),
  26. # 必须把 Host/Origin 改写为 127.0.0.1:3080 使 dsh 视为本机来源;
  27. # Origin 必须与改写后 Host 同源,否则 fence 的 Origin 检查仍 403
  28. # - http:// 前缀显式声明纯 HTTP 站点,禁用 auto-HTTPS/本地 CA
  29. #
  30. # Notes:
  31. # - Must listen on 0.0.0.0 inside the container (Docker port mapping DNATs to container eth0; binding loopback rejects mapped traffic)
  32. # - DSH 0.1.2-rc.1's web mode is hard-locked to loopback bind (upstream explicitly rejects
  33. # --host 0.0.0.0); reverse-proxy is currently the only path to expose 3080 externally
  34. # - DSH privileged APIs (settings.*/credentials.*) accept only loopback origins (anti-DNS-rebinding),
  35. # Host/Origin must be rewritten to 127.0.0.1:3080 so dsh treats it as a local origin;
  36. # Origin must match the rewritten Host, otherwise the fence's Origin check still returns 403
  37. # - The http:// prefix explicitly declares a plain-HTTP site, disabling auto-HTTPS/local CA
  38. http://:3081 {
  39. reverse_proxy 127.0.0.1:3080 {
  40. header_up Host 127.0.0.1:3080
  41. header_up Origin http://127.0.0.1:3080
  42. }
  43. }