# Local dev reverse-proxy with auto-generated internal TLS certificates. # Requires DNS: local.example.com & *.local.example.com → 127.0.0.1 # Also supports Coder Desktop via $CODER_WORKSPACE_NAME (e.g. myapp-local): # {CODER_WORKSPACE_NAME}.coder → landing # app.{CODER_WORKSPACE_NAME}.coder → app + API { admin localhost:2020 http_port 8080 https_port 4443 # REQUIRED for Coder Desktop port scanning: Coder's port-scanner only detects # TCP4 sockets. Without this, Caddy binds to dual-stack [::] and the proxy # ports are invisible to Coder's port-forward infrastructure. default_bind tcp4/0.0.0.0 } # Landing page – local.example.com → Vite/Next.js dev server local.example.com { tls internal reverse_proxy localhost:3000 { header_up Host localhost:3000 } } # App + API – app.local.example.com app.local.example.com { tls internal # /api/* → FastAPI backend (path forwarded as-is) handle /api/* { reverse_proxy localhost:8000 } # Everything else → Next.js UI handle { reverse_proxy localhost:3000 } } # Coder Desktop – landing ({$CODER_WORKSPACE_NAME}.coder) # Falls back to a no-op placeholder host when CODER_WORKSPACE_NAME is unset. {$CODER_WORKSPACE_NAME:coder-workspace-placeholder}.coder { tls internal reverse_proxy localhost:3000 { header_up Host localhost:3000 } } # Coder Desktop – app + API (app.{$CODER_WORKSPACE_NAME}.coder) app.{$CODER_WORKSPACE_NAME:coder-workspace-placeholder}.coder { tls internal # /api/* → FastAPI backend (path forwarded as-is) handle /api/* { reverse_proxy localhost:8000 } # Everything else → Next.js UI handle { reverse_proxy localhost:3000 } } # Coder web port-forwarding catch-all ───────────────────────────────────────── # Coder's browser-based port-forwarding (https://--.coder.domain/) # terminates TLS at the Coder edge and forwards plain HTTP to the workspace port. # Named site blocks above won't match the Coder-generated Host header, so this # http:// catch-all handles those requests on port 8080 (the http_port). # Use URL: https://8080--main----.coder./ http:// { handle /api/* { reverse_proxy localhost:8000 } handle { reverse_proxy localhost:3000 } }