In Compose, Nest is strongest when the API container never publishes its listen port on the host and a reverse proxy is the only public listener. Resolve the Nest service by Compose DNS name and internal port — not a host-mapped address — so a recreate cannot leave the edge chasing a stale published port. Forward Host plus X-Forwarded-For / X-Forwarded-Proto into Nest so absolute URLs, cookies, and Swagger “try it” calls stay on the public scheme. Keep Prisma’s database on the same user-defined network and leave the DB port unpublished; pin proxy_http_version 1.1 with Connection cleared for keepalive into the Node process.
Path joining and stale upstream DNS still cause most post-redeploy 502s: a trailing-slash mismatch between location and proxy_pass doubles or strips a prefix, and a long-lived proxy worker can keep a dead task IP after recreate unless you use a variable-plus-resolver pattern or recreate the proxy on deploy. After compose up I hit the Nest service name from inside the proxy container first, then the same path through published 80/443, and compare status and timing. Expose a cheap readiness path that checks the Nest process (and optionally a Prisma ping) so orchestrators do not treat a hung event loop as healthy.
Node Edge Ops
In Compose, Nest is strongest when the API container never publishes its listen port on the host and a reverse proxy is the only public listener. Resolve the Nest service by Compose DNS name and internal port — not a host-mapped address — so a recreate cannot leave the edge chasing a stale published port. Forward Host plus X-Forwarded-For / X-Forwarded-Proto into Nest so absolute URLs, cookies, and Swagger “try it” calls stay on the public scheme. Keep Prisma’s database on the same user-defined network and leave the DB port unpublished; pin proxy_http_version 1.1 with Connection cleared for keepalive into the Node process.
Path joining and stale upstream DNS still cause most post-redeploy 502s: a trailing-slash mismatch between location and proxy_pass doubles or strips a prefix, and a long-lived proxy worker can keep a dead task IP after recreate unless you use a variable-plus-resolver pattern or recreate the proxy on deploy. After compose up I hit the Nest service name from inside the proxy container first, then the same path through published 80/443, and compare status and timing. Expose a cheap readiness path that checks the Nest process (and optionally a Prisma ping) so orchestrators do not treat a hung event loop as healthy.