Caddyfile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # FrankenPHP Caddyfile for the ui container.
  2. # Serves Slim from public/ on :8080.
  3. {
  4. frankenphp
  5. order php_server before file_server
  6. auto_https off
  7. admin off
  8. servers {
  9. trusted_proxies static private_ranges
  10. }
  11. }
  12. :8080 {
  13. root * /app/public
  14. encode zstd gzip
  15. # ── Security headers (M14) ──────────────────────────────────────────
  16. # CSP is set per-response by `App\Http\CspMiddleware` so the
  17. # `script-src 'nonce-…'` value can change per request, dropping
  18. # `'unsafe-inline'` / `'unsafe-eval'` (SEC_REVIEW F24).
  19. header {
  20. -Server
  21. -X-Powered-By
  22. X-Content-Type-Options "nosniff"
  23. X-Frame-Options "DENY"
  24. Referrer-Policy "strict-origin-when-cross-origin"
  25. # SEC_REVIEW F61: extended deny-list for browser features
  26. # the admin UI never uses. The narrow `geolocation=(),
  27. # microphone=(), camera=()` was the M14 starter; this is the
  28. # full hardening list. `clipboard-read` is blocked but
  29. # `clipboard-write` is left at its same-origin default so
  30. # the "copy raw token" button (rawTokenCopy Alpine
  31. # component) still works on the Tokens page.
  32. Permissions-Policy "accelerometer=(), ambient-light-sensor=(), autoplay=(), battery=(), bluetooth=(), camera=(), clipboard-read=(), display-capture=(), encrypted-media=(), fullscreen=(), gamepad=(), geolocation=(), gyroscope=(), hid=(), idle-detection=(), interest-cohort=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), screen-wake-lock=(), serial=(), speaker-selection=(), usb=(), web-share=(), xr-spatial-tracking=()"
  33. # SEC_REVIEW F59: modern cross-origin isolation headers.
  34. # - COOP `same-origin` isolates the browsing context from any
  35. # popups it opens; a `window.opener.location = …` from a
  36. # newly-spawned cross-origin tab can no longer reach back.
  37. # - CORP `same-origin` tells the browser this resource may
  38. # only be loaded by same-origin documents (defeats sub-
  39. # resource leaks via cross-origin <img>/<script>/<link>
  40. # inclusion).
  41. # - X-Permitted-Cross-Domain-Policies `none` blocks legacy
  42. # Adobe Flash / Acrobat cross-domain.xml lookups.
  43. # COEP `require-corp` is deliberately NOT set — that requires
  44. # every cross-origin resource (e.g. the jsDelivr-hosted
  45. # RapiDoc on /api/docs) to opt in via CORP, which we don't
  46. # control. We're only after the COOP/CORP/legacy-Flash
  47. # benefits the SEC_REVIEW called out.
  48. Cross-Origin-Opener-Policy "same-origin"
  49. Cross-Origin-Resource-Policy "same-origin"
  50. X-Permitted-Cross-Domain-Policies "none"
  51. }
  52. # HSTS: prod-only (setting it in dev would lock you out of plain-HTTP
  53. # localhost on the same hostname for a year). The value is operator-
  54. # tuneable via the `HSTS_HEADER` env var so a deployment that wants
  55. # to apply for the browser preload list can opt in by setting:
  56. # HSTS_HEADER="max-age=31536000; includeSubDomains; preload"
  57. # Default keeps the conservative no-preload value — preload-listing
  58. # is a one-way commitment (browser preload removals take months) so
  59. # we don't enable it by default (SEC_REVIEW F60).
  60. @prod expression `{env.APP_ENV} == "production"`
  61. header @prod Strict-Transport-Security "{$HSTS_HEADER:max-age=31536000; includeSubDomains}"
  62. # Public /about landing page — served as the static about.html file
  63. # so it works without going through Slim or the auth middleware.
  64. @about path /about
  65. rewrite @about /about.html
  66. php_server
  67. }