// the find
leerob/next-self-host
An example deploying Next / Postgres / Nginx to a Ubuntu Linux server.
A working example showing how to run Next.js with Postgres and Nginx on a plain Ubuntu VPS, without Vercel. Written by Next.js's former DX lead, so it covers the non-obvious bits like custom cache handlers and ISR outside of the Vercel platform. Aimed at developers who want full server control but don't want to piece together the Docker/Nginx config themselves.
The deploy.sh script is genuinely useful — SSL via Let's Encrypt, rate limiting in Nginx, Docker Compose wiring, all in one pass. The custom cache-handler.mjs is the most valuable file here; Next.js ISR off-platform is poorly documented and this gives you a concrete starting point. Covers instrumentation.ts for server startup hooks, which most examples skip. The update.sh companion script acknowledges that deployment isn't a one-time event, which most hello-world repos ignore.
Database setup after deploy is manual psql — the script doesn't run migrations, so your first deploy leaves you with an empty schema and instructions to exec into the container. The Postgres container has no named volume in the compose file, so a docker-compose down loses your data. No secrets management beyond writing a .env file as root on the server. This is a demo, not a production template, but the line between the two gets blurry given the polished deploy script.