From 43db707e34fb1f35fbec3dcd52ef61c96d2a46cf Mon Sep 17 00:00:00 2001 From: Jakub Dorfman Date: Wed, 19 Aug 2026 21:16:12 +0200 Subject: [PATCH] added configurable modes to caddy http/https --- .env.example | 6 ++++++ Caddyfile | 19 +++++++++++-------- docker-compose.yml | 4 ++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index ecc5194..65b8615 100644 --- a/.env.example +++ b/.env.example @@ -10,3 +10,9 @@ STRIPE_CURRENCY=eur # PocketBase superuser credentials (used by server-side basket/checkout/webhook APIs) POCKETBASE_ADMIN_EMAIL=admin@example.com POCKETBASE_ADMIN_PASSWORD=changeme + +# Caddy scheme for the reverse proxy on port 8080. +# http (default) — plain HTTP; matches the ORIGIN vars in docker-compose.yml +# https — HTTPS on :8080 (self-signed unless you add a cert issuer; +# also update ORIGIN/PUBLIC_* URLs to https://...) +CADDY_SCHEME=http diff --git a/Caddyfile b/Caddyfile index 9b92a19..5a4f529 100644 --- a/Caddyfile +++ b/Caddyfile @@ -1,23 +1,26 @@ -# Reverse proxy — subdomain-based routing (plain HTTP on port 8080) +# Reverse proxy — subdomain-based routing on port 8080 # admin.{$DOMAIN} → app-admin (SvelteKit admin app) # db.{$DOMAIN} → PocketBase (redirects / to /_/) # *.{$DOMAIN} → app-public (SvelteKit public app) # -# The `http://` prefix disables Caddy's automatic HTTPS so the site is served -# as plain HTTP on port 8080. This matches the ORIGIN env vars in -# docker-compose.yml (http://admin.${DOMAIN}:8080 etc.) so SvelteKit's CSRF -# protection accepts form POSTs. +# The scheme is controlled by the {$CADDY_SCHEME} env var (default: http). +# - http → plain HTTP (disables Caddy's automatic HTTPS). Matches the ORIGIN +# env vars in docker-compose.yml (http://admin.${DOMAIN}:8080 etc.) +# so SvelteKit's CSRF protection accepts form POSTs. +# - https → HTTPS. On a non-standard port (8080) Caddy will issue internal +# self-signed certificates unless you configure a real cert issuer. +# Remember to also update ORIGIN/PUBLIC_* URLs in docker-compose.yml. -http://admin.{$DOMAIN}:8080 { +{$CADDY_SCHEME}://admin.{$DOMAIN}:8080 { reverse_proxy app-admin:3001 } -http://db.{$DOMAIN}:8080 { +{$CADDY_SCHEME}://db.{$DOMAIN}:8080 { # PocketBase admin UI lives at /_/ — redirect bare root there. redir / /_/{path} reverse_proxy pocketbase:80 } -http://www.{$DOMAIN}:8080, http://*.{$DOMAIN}:8080 { +{$CADDY_SCHEME}://www.{$DOMAIN}:8080, {$CADDY_SCHEME}://*.{$DOMAIN}:8080 { reverse_proxy app-public:3000 } diff --git a/docker-compose.yml b/docker-compose.yml index a780364..40bfcae 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -63,6 +63,10 @@ services: - "8080:8080" environment: DOMAIN: ${DOMAIN:-localhost} + # Scheme used in Caddyfile site addresses. "http" = plain HTTP on :8080 + # (matches the ORIGIN vars below). Switch to "https" only if you also + # update ORIGIN/PUBLIC_* URLs and provide a cert issuer. + CADDY_SCHEME: ${CADDY_SCHEME:-http} volumes: - ./Caddyfile:/etc/caddy/Caddyfile:ro,Z depends_on: