Caddyfile 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #
  2. {
  3. debug
  4. skip_install_trust
  5. }
  6. {$SERVER_NAME:localhost} {
  7. # Enable compression (optional)
  8. encode zstd br gzip
  9. # Long-lived caching for real static assets. Storage (/s/*) serves files
  10. # through storage.php, which sets its own headers (private files included),
  11. # so it is excluded here.
  12. @static {
  13. path *.woff2 *.woff *.ttf *.otf *.eot *.svg *.png *.jpg *.jpeg *.gif *.webp *.avif *.ico *.css *.js *.mjs *.map
  14. not path /s/*
  15. }
  16. header @static Cache-Control "public, max-age=2592000"
  17. # Add trailing slash for directory requests
  18. @canonicalPath {
  19. file {path}/index.php
  20. not path */
  21. }
  22. redir @canonicalPath {path}/ 308
  23. @unapages path_regexp ^/page/(.*)$
  24. rewrite @unapages /page.php?i={re.unapages.1}
  25. @unamodules path_regexp ^/m/(.*)$
  26. rewrite @unamodules /modules/index.php?r={re.unamodules.1}
  27. @unastorage path_regexp ^/s/([a-zA-Z0-9_]+)/([a-zA-Z0-9\.]+)
  28. rewrite @unastorage /storage.php?o={re.unastorage.1}&f={re.unastorage.2}
  29. @unaMissing {
  30. not file
  31. not path */
  32. path_regexp una ^/(.+)$
  33. }
  34. rewrite @unaMissing /r.php?_q={re.una.1}&{query}
  35. try_files {path} {path}/index.php {path}/index.html
  36. # FrankenPHP!
  37. @phpFiles path *.php
  38. php @phpFiles
  39. file_server
  40. }