diff --git a/conf/Caddyfile b/conf/Caddyfile index b7abd5f..32f0b9c 100644 --- a/conf/Caddyfile +++ b/conf/Caddyfile @@ -1,3 +1,5 @@ +#(simpleAuth) + (common) { encode gzip zstd header { @@ -7,58 +9,115 @@ } test.gynther.se { - respond "det fungerar" + respond "det fungerar" } bazarr.gynther.se { - import common - reverse_proxy http://bazarr:6767 + import common + reverse_proxy http://bazarr:6767 } prowlarr.gynther.se { - import common - reverse_proxy http://prowlarr:9696 + import common + reverse_proxy http://prowlarr:9696 } radarr.gynther.se { - import common - reverse_proxy http://radarr:7878 + import common + reverse_proxy http://radarr:7878 } sonarr.gynther.se { - import common - reverse_proxy http://sonarr:8989 + import common + reverse_proxy http://sonarr:8989 } jellyfin.gynther.se { - reverse_proxy http://jellyfin:8096 -} -qbittorrent.gynther.se { - import common - reverse_proxy 192.168.50.4:8080 -} -wetty.gynther.se { - import common - basic_auth { - admin $2a$14$DahHUWD2cKyXJ96sH5VQwuQv1bqmIn0gsdoSaw4mofzfdNY2Y0VsO - } - redir / /wetty - reverse_proxy wetty:3000 -} -portainer.gynther.se { - reverse_proxy portainer:9000 -} -recept.gynther.se { - import common - reverse_proxy recipe-frontend:3000 + reverse_proxy http://jellyfin:8096 } -api.recept.gynther.se { - import common - reverse_proxy recipe-api:8080 +qbittorrent.gynther.se { + import common + reverse_proxy 192.168.50.4:8080 +} + +wetty.gynther.se { + import common + basic_auth { + admin $2a$14$DahHUWD2cKyXJ96sH5VQwuQv1bqmIn0gsdoSaw4mofzfdNY2Y0VsO + } + redir / /wetty + reverse_proxy wetty:3000 +} + +portainer.gynther.se { + reverse_proxy portainer:9000 } gitea.gynther.se { import common reverse_proxy 192.168.50.2:3002 } + +# ============================================ +# Import Service (Document Converter) - Standalone UI +# ============================================ +import.gynther.se { + import common + reverse_proxy recipe-import-service:3000 +} + +# ============================================ +# RECIPE APP + IMPORT SERVICE +# ============================================ +recept.gynther.se { + import common + + # === IMPORT SERVICE (Document Converter) === + # Dessa endpoints måste komma FÖRST innan backend reglerna! + handle /api/recipes/import* { + reverse_proxy recipe-import-service:3000 + } + + # === RECIPE FRONTEND PROXY ENDPOINTS === + # Next.js API routes + handle /api/inventory-history-proxy { + reverse_proxy recipe-frontend:3000 + } + + handle /api/admin/merge-preview-proxy { + reverse_proxy recipe-frontend:3000 + } + + handle /api/recipe-preview-proxy { + reverse_proxy recipe-frontend:3000 + } + + # === RECIPE BACKEND API ENDPOINTS === + # Backend körs på port 8080 (från docker-compose) + handle /api/products* { + reverse_proxy recipe-api:8080 + } + + handle /api/inventory* { + reverse_proxy recipe-api:8080 + } + + handle /api/recipes* { + reverse_proxy recipe-api:8080 + } + + # === HEALTH CHECKS === + handle /health { + reverse_proxy recipe-api:8080 + } + + # === CATCH ALL === + # Övriga /api/* går till frontend + handle /api/* { + reverse_proxy recipe-frontend:3000 + } + + # Frontend - catch all remaining routes (port 3000) + reverse_proxy /* recipe-frontend:3000 +} diff --git a/conf/Caddyfile.2026-04-11 b/conf/Caddyfile.2026-04-11 new file mode 100644 index 0000000..8d7a9c7 --- /dev/null +++ b/conf/Caddyfile.2026-04-11 @@ -0,0 +1,89 @@ +(common) { + encode gzip zstd + header { + X-Frame-Options "SAMEORIGIN" + X-Content-Type-Options "nosniff" + } +} + +test.gynther.se { + respond "det fungerar" +} + +bazarr.gynther.se { + import common + reverse_proxy http://bazarr:6767 +} + +prowlarr.gynther.se { + import common + reverse_proxy http://prowlarr:9696 +} + +radarr.gynther.se { + import common + reverse_proxy http://radarr:7878 +} + +sonarr.gynther.se { + import common + reverse_proxy http://sonarr:8989 +} + +jellyfin.gynther.se { + reverse_proxy http://jellyfin:8096 +} +qbittorrent.gynther.se { + import common + reverse_proxy 192.168.50.4:8080 +} +wetty.gynther.se { + import common + basic_auth { + admin $2a$14$DahHUWD2cKyXJ96sH5VQwuQv1bqmIn0gsdoSaw4mofzfdNY2Y0VsO + } + redir / /wetty + reverse_proxy wetty:3000 +} +portainer.gynther.se { + reverse_proxy portainer:9000 +} + +gitea.gynther.se { + import common + reverse_proxy 192.168.50.2:3002 +} + +recept.gynther.se { + import common + + # Proxy-endpoints för Next.js (måste komma FÖRE backend-reglerna!) + handle /api/inventory-history-proxy { + reverse_proxy recipe-frontend:3000 + } + handle /api/admin/merge-preview-proxy { + reverse_proxy recipe-frontend:3000 + } + handle /api/recipe-preview-proxy { + reverse_proxy recipe-frontend:3000 + } + + # Proxy backend-API till backend + handle /api/products* { + reverse_proxy recipe-api:8080 + } + handle /api/inventory* { + reverse_proxy recipe-api:8080 + } + handle /api/recipes* { + reverse_proxy recipe-api:8080 + } + + # Alla andra /api/* går till Next.js (frontend) + handle /api/* { + reverse_proxy recipe-frontend:3000 + } + + # Allt annat går till frontend + reverse_proxy recipe-frontend:3000 +} diff --git a/conf/Caddyfile.importer b/conf/Caddyfile.importer new file mode 100644 index 0000000..3ff546a --- /dev/null +++ b/conf/Caddyfile.importer @@ -0,0 +1,79 @@ +# Caddyfile - Reverse Proxy Configuration +# Development setup för recipe-app + import-service +# +# Routing: +# - Frontend: :4000 → localhost/ +# - Backend API: :3001 → localhost/api/ +# - Import Service: :3000 → localhost/api/recipes/import/ +# +# Production setup: Ersätt localhost med din domain + +localhost { + # ============================================ + # IMPORT SERVICE (Document Converter) + # ============================================ + # Dessa endpoints måste komma FÖRST! + # POST /api/recipes/import/pdf - Importera PDF (preview) + # POST /api/recipes/import/pdf/save - Importera och spara + # GET /api/recipes/import/health - Health check + + handle /api/recipes/import* { + reverse_proxy recipe-import-service:3000 + } + + # ============================================ + # RECIPE FRONTEND PROXY ENDPOINTS + # ============================================ + # Next.js API routes som proxy + + handle /api/inventory-history-proxy { + reverse_proxy recipe-app-backend:3001 + } + + handle /api/admin/merge-preview-proxy { + reverse_proxy recipe-app-backend:3001 + } + + handle /api/recipe-preview-proxy { + reverse_proxy recipe-app-backend:3001 + } + + # ============================================ + # RECIPE BACKEND API ENDPOINTS + # ============================================ + + handle /api/products* { + reverse_proxy recipe-app-backend:3001 + } + + handle /api/inventory* { + reverse_proxy recipe-app-backend:3001 + } + + handle /api/recipes* { + reverse_proxy recipe-app-backend:3001 + } + + # ============================================ + # HEALTH CHECKS + # ============================================ + + handle /health { + reverse_proxy recipe-app-backend:3001 + } + + # ============================================ + # CATCH ALL + # ============================================ + + # Övriga /api/* går till frontend + handle /api/* { + reverse_proxy recipe-app-frontend:4000 + } + + # Frontend - catch all remaining routes + reverse_proxy /* recipe-app-frontend:4000 + + # Enable gzip compression + encode gzip +}