From 01bd5662c3ac5de6160eed30964942ee56fe72fa Mon Sep 17 00:00:00 2001 From: Mortexa <47121888+smortexa@users.noreply.github.com> Date: Fri, 20 Dec 2024 17:31:42 +0330 Subject: [PATCH] Add support for custom `caddyfile` (#106) --- deployment/octane/FrankenPHP/Caddyfile | 61 +++++++++++++++++++ .../FrankenPHP/supervisord.frankenphp.conf | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 deployment/octane/FrankenPHP/Caddyfile diff --git a/deployment/octane/FrankenPHP/Caddyfile b/deployment/octane/FrankenPHP/Caddyfile new file mode 100644 index 0000000..e39f964 --- /dev/null +++ b/deployment/octane/FrankenPHP/Caddyfile @@ -0,0 +1,61 @@ +{ + {$CADDY_GLOBAL_OPTIONS} + + admin {$CADDY_SERVER_ADMIN_HOST}:{$CADDY_SERVER_ADMIN_PORT} + + frankenphp { + worker "{$APP_PUBLIC_PATH}/frankenphp-worker.php" {$CADDY_SERVER_WORKER_COUNT} + } + + servers { + metrics + } +} + +{$CADDY_SERVER_SERVER_NAME} { + log { + level WARN + + format filter { + wrap {$CADDY_SERVER_LOGGER} + fields { + uri query { + replace authorization REDACTED + } + } + } + } + + route { + root * "{$APP_PUBLIC_PATH}" + encode zstd br gzip + + {$CADDY_SERVER_EXTRA_DIRECTIVES} + + request_body { + max_size 500MB + } + + @static { + file + path *.js *.css *.jpg *.jpeg *.webp *.weba *.webm *.gif *.png *.ico *.cur *.gz *.svg *.svgz *.mp4 *.mp3 *.ogg *.ogv *.htc *.woff2 *.woff + } + + @staticshort { + file + path *.json *.xml *.rss + } + + header @static Cache-Control "public, immutable, stale-while-revalidate, max-age=31536000" + + header @staticshort Cache-Control "no-cache, max-age=3600" + + @rejected `path('*.bak', '*.conf', '*.dist', '*.fla', '*.ini', '*.inc', '*.inci', '*.log', '*.orig', '*.psd', '*.sh', '*.sql', '*.swo', '*.swp', '*.swop', '*/.*') && !path('*/.well-known/')` + error @rejected 401 + + php_server { + index frankenphp-worker.php + resolve_root_symlink + } + } +} diff --git a/deployment/octane/FrankenPHP/supervisord.frankenphp.conf b/deployment/octane/FrankenPHP/supervisord.frankenphp.conf index af83665..8fc924e 100644 --- a/deployment/octane/FrankenPHP/supervisord.frankenphp.conf +++ b/deployment/octane/FrankenPHP/supervisord.frankenphp.conf @@ -1,6 +1,6 @@ [program:octane] process_name=%(program_name)s_%(process_num)s -command=php %(ENV_ROOT)s/artisan octane:start --server=frankenphp --host=0.0.0.0 --port=8000 --admin-port=2019 +command=php %(ENV_ROOT)s/artisan octane:start --server=frankenphp --host=0.0.0.0 --port=8000 --admin-port=2019 --caddyfile=./deployment/octane/FrankenPHP/Caddyfile user=%(ENV_USER)s autostart=true autorestart=true