Skip to content

ADR-0002. Local Nginx route table for native-dev parity

FieldValue
StatusAccepted
Date2025-01-20
Deciders@platform
Supersedes

Context

  • In native development services run directly on the host (127.0.0.1:31xx), not in Docker — so Traefik's Docker-label discovery does not apply.
  • The frontend wants a single base URL (http://sgw.local.bana.com.vn/v1/api) regardless of which service it calls, mirroring the production edge.
  • Running the full Docker/Traefik stack locally is heavy and slows the inner dev loop.
  • Service prefixes already match APP_ENV_SERVER_BASE_PATH, so no path rewriting is needed.

Decision

We will front native services with a single Nginx container (local-nx-gateway) using host networking, driven by an explicit central route table in local/nginx.conf (upstream blocks + location /v1/api/<svc>/ per service, plus /stream and /__gateway_health).

Consequences

ProsCons
One stable base URL for the FE — matches prod edge behaviorHost networking is Linux-only
Lightweight — single container, no Traefik/Docker stackRoute table is manual: each new service needs an upstream + location edit
Unmatched paths fail fast with a clear 404 JSONTwo route definitions to keep in sync (prod labels vs dev nginx.conf)
WebSocket /stream and a health probe work locallyNo resilience middlewares in dev (intentional — closer to raw service behavior)

Alternatives Considered

OptionProsConsWhy rejected
Run Traefik locally tooIdentical proxy to prodRequires Docker-izing every dev service; heavyDefeats the fast native-dev loop
FE points directly at each 127.0.0.1:31xxNo gateway at allMany base URLs; no prod parity; CORS painPoor DX, diverges from prod
Docker Compose dev stack with TraefikFull paritySlow rebuilds, resource-heavyInner-loop friction

References

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.