Files
sendico/frontend/pweb/caddy/Caddyfile
2025-11-18 17:32:23 +01:00

135 lines
3.2 KiB
Caddyfile

########################################
# Global options
########################################
{
email {$CADDY_ACME_EMAIL}
# debug
}
########################################
# Sendico site definition
########################################
(sendico_site) {
vars static_root /usr/share/pweb
encode zstd gzip
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
}
route {
########################################
# Backend API
########################################
handle /api/v1/* {
# Allow overriding upstream via API_UPSTREAM, default to the BFF container.
reverse_proxy {$API_UPSTREAM:sendico-bff:8081} {
health_uri /api/v1/health
health_interval 15s
health_timeout 4s
health_status 2xx
}
header Cache-Control "no-cache, no-store, must-revalidate"
header Pragma "no-cache"
header Expires "0"
}
########################################
# Static assets with tailored caching
########################################
handle /version.json {
root * {vars.static_root}
file_server
header Cache-Control "no-cache, no-store, must-revalidate"
header Pragma "no-cache"
header Expires "0"
}
handle /*.main.dart.js {
root * {vars.static_root}
file_server
header Cache-Control "public, max-age=3600"
}
handle /*.dart.js {
root * {vars.static_root}
file_server
header Cache-Control "public, max-age=3600"
}
handle /*.js {
root * {vars.static_root}
file_server
header Cache-Control "public, max-age=3600"
}
handle /assets/*.js {
root * {vars.static_root}
file_server
header Cache-Control "public, max-age=31536000, immutable"
}
handle /assets/*.css {
root * {vars.static_root}
file_server
header Cache-Control "public, max-age=31536000, immutable"
}
handle /assets/* {
root * {vars.static_root}
file_server
header Cache-Control "public, max-age=31536000, immutable"
}
handle /canvaskit/* {
root * {vars.static_root}
file_server
header Cache-Control "public, max-age=86400"
}
handle /icons/* {
root * {vars.static_root}
file_server
header Cache-Control "public, max-age=86400"
}
handle /*.html {
root * {vars.static_root}
file_server
header Cache-Control "public, max-age=3600"
}
handle /*.css {
root * {vars.static_root}
file_server
header Cache-Control "public, max-age=3600"
}
handle /*.json {
root * {vars.static_root}
file_server
header Cache-Control "public, max-age=3600"
}
########################################
# SPA fallback
########################################
handle {
root * {vars.static_root}
try_files {path} /index.html
file_server
header Cache-Control "no-cache, no-store, must-revalidate"
header Pragma "no-cache"
header Expires "0"
}
}
}
########################################
# Main site
########################################
{$SERVICE_HOST} {
import sendico_site
}