#Nginx + Docker + Nextjs SSR

12 messages · Page 1 of 1 (latest)

opal kiln
#

Hi I am trying to setup a configuration for nginx and docker for a SSR nextjs build and I am really struggling here anyone did it before ?

quartz hare
#

The blog formatting can be a lil bit confusing but it's really helpful.

opal kiln
#

thank you i will try now

scarlet mulch
#

Except pm2 is excessive, just use package manager command to start process

opal kiln
#

yes thank you
i tried this too and it work expect that i need one Dockerfile for both nginx and next

scarlet mulch
#

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

opal kiln
#

yeah i would love to do that
but apparently m not allowed bc of the company's azure templates or whatever

quartz hare
#

Is it possible for you to install nginx outside the container and the app in the container?

merry granite
#

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?