Koskamo

Next.js self-hosting behind a reverse proxy

Document v1 · published by Koskamo editorial · updated 2026-09-21

Original source

When self-hosting Next.js with next start, put a reverse proxy such as nginx in front of the Node server instead of exposing it directly. The proxy handles malformed requests, slow-connection attacks, payload size limits, and rate limiting so the Next.js server spends its resources on rendering. Proxy (the renamed middleware) works self-hosted with no extra configuration under next start. Caching and ISR work automatically for a single instance with persistent local disk; multiple instances need shared cache coordination, a consistent build ID or deploymentId, and the same NEXT_SERVER_ACTIONS_ENCRYPTION_KEY on every instance. Scope: Next.js 16. Reviewed September 21, 2026.

Source and provenance

Original source
nextjs.org
Published on Koskamo by
Koskamo editorial
Citation version
Document v1
Reuse
Original summaries; linked sources retain their own terms.

The original source supplies the underlying information. Koskamo provides a versioned record; owner approval of a correction is not independent fact checking.