#Nginx + Docker + Nextjs SSR
12 messages · Page 1 of 1 (latest)
Docker: I copied Dockerfile and .dockerignore from one of vercel's example here https://github.com/vercel/next.js/tree/canary/examples/with-docker then added output: 'standalone' in module.exports in next.config.js
For setting up the reverse proxy in nginx, I've used this guide: https://www.digitalocean.com/community/questions/how-to-host-multiple-docker-containers-on-a-single-droplet-with-nginx-reverse-proxy
The blog formatting can be a lil bit confusing but it's really helpful.
thank you i will try now
I made it work by following this article https://steveholgado.com/nginx-for-nextjs/
Tutorial | Set up a production Docker environment for a Next.js app with NGINX as a reverse-proxy with server caching
Except pm2 is excessive, just use package manager command to start process
yes thank you
i tried this too and it work expect that i need one Dockerfile for both nginx and next
The main idea behind containerization is having each app inside separate containers. Are you sure you want them inside together? You could probably omit daemon off
yeah i would love to do that
but apparently m not allowed bc of the company's azure templates or whatever
Is it possible for you to install nginx outside the container and the app in the container?
I followed these tutorials and everything works well except for the embedded /api endpoint handled by NextJS. The app always answers Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client from the at ServerResponse.apiRes.json (/app/node_modules/next/dist/server/api-utils/node.js:162:31) call because it seems to be in conflicts with Nginx.
Do someone knows how to fix this, making nginx bypassing the /api calls that must be handled by the app?