# Snippets shared by Caddyfile (prod) and Caddyfile.dev, imported right after # their global options block (global.caddy). # Site-level settings shared by both environments. (site) { root * /var/www/html/public # New with Caddy: nginx compressed nothing. Caddy only compresses text # types (HTML, CSS, JS, JSON, SVG…), never images or fonts. encode zstd gzip # Same upload limit as nginx's client_max_body_size (and php.ini). request_body { max_size 100MiB } # On every response. nginx only added these to static files and 2xx/3xx # (prod's PHP location dropped them). header { X-Frame-Options "SAMEORIGIN" X-Content-Type-Options "nosniff" # Caddy's proxy adds Via; nginx sent none. A deletion is applied as # the response goes out, so it also catches headers set later. -Via } # Access log to stdout, as nginx did; favicon/robots skipped like nginx. log @quiet path /favicon.ico /robots.txt log_skip @quiet } # Dotfiles (.env, .git…) are never served; /.well-known/ is allowed. # Use inside a route block, first. (deny_dotfiles) { @dotfiles { path */.* not path /.well-known/* } respond @dotfiles 403 } # Stoic (the headless CMS) under /stoic/, prefix stripped, cookies scoped to # /stoic/ (nginx: proxy_cookie_path / /stoic/). (stoic) { handle_path /stoic/* { reverse_proxy stoic:2727 { header_up X-Real-IP {client_ip} header_down Set-Cookie "(?i)(;\s*path=)/" "$1/stoic/" } } } # Laravel. php_fastcgi does the try_files (file, dir/index.php, index.php); # file_server serves the files that exist in public/. (laravel) { php_fastcgi app:9000 { read_timeout 300s # PHP-FPM's CGI status line; nginx didn't pass it on either. header_down -Status } file_server } # A missing file under one of prod's static paths (/build/, /storage/…): a # plain 404, without the Cache-Control/Content-Type that path's handle already # set. # (nginx sent these to Laravel via `error_page 404 /index.php`, kept the 404 # status and showed Laravel's page; nobody sees that page for an asset.) (static_404) { handle_errors 404 { header -Cache-Control header Content-Type "text/plain; charset=utf-8" respond "Not Found" 404 } }