fix(deploy): isolate web→api traffic on a private network

nginx proxied to `api:4100` over the shared `dokploy-network`, where the
generic name `api` resolved to more than one container (a stale one from a
previous deploy, or another project's service). nginx pinned those IPs at
startup and round-robined across them, so requests hit a refused upstream
and could reach a foreign container.

- api now lives only on a stack-private `internal` network, aliased as
  `superlist-api`; only web joins `dokploy-network` for Traefik.
- nginx proxies via a variable with Docker's resolver (127.0.0.11,
  valid=10s), so API redeploys never leave it on a stale IP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jose Selesan
2026-10-19 12:05:20 -03:00
parent 371e59de92
commit 815dcc300d
4 changed files with 31 additions and 11 deletions

View File

@@ -53,9 +53,11 @@ same Biome check as `biome ci` would.
`docker-compose.yml` at the repo root defines the two runtime services — `api` (Bun + nginx-free Hono server)
and `web` (static build behind nginx, proxying `/api/*` to the API). The database is external (provided by
Dokploy), and both services join the external `dokploy-network` so Traefik can reach them.
Dokploy). Only `web` joins the external `dokploy-network` so Traefik can reach it; `web` and `api` talk over
the stack-private `internal` network, where the API answers to the unique alias `superlist-api` (a generic
name like `api` on the shared network could resolve to another project's container).
- One public domain: nginx serves the SPA and proxies `/api/*` → `http://api:4100`. All API routes are
- One public domain: nginx serves the SPA and proxies `/api/*` → `http://superlist-api:4100`. All API routes are
mounted under `/api` for that reason — never mount a route at the root of the API.
- Env vars are interpolated from the Dokploy service env (`docker-compose.yml` marks `DATABASE_URL`,
`BETTER_AUTH_SECRET`, `BETTER_AUTH_URL`, `CORS_ORIGIN` and `WEB_APP_URL` as required). See `.env.example`.