Next.js Discord

Discord Forum

Nextjs on vercel with nginx as reverse proxy VS Nextjs on docker with nginx as reverse proxy

Unanswered
Prabhakar Yadav posted this in #help-forum
Open in Discord
I'm building a containerized application for my project, and I decieded to use NextJs only for the frontend part

I'm currently using nginx as a reverse proxy for my server containers and set it up to work with nextjs development mode using a node container,

My doubt is for production which option is good ?

1. Host nextjs on vercel and configure vercels url in my nginx as reverse proxy i.e nginx will come at front but I was reading online and I saw this github discussion where it was suggested not to do like this https://github.com/vercel/vercel/discussions/5769

2. Host nextjs on vercel and make proxy my API request to nginx (using nextjs rewrites) but I found a comment on stackoverflow saying it don't work well with socket.io https://stackoverflow.com/questions/60925133/proxy-to-backend-with-default-next-js-dev-server#comment117860996_65467719

3. Use nginx as my main proxy and deploy nextjs in node container (an example I found on nextjs repo: https://github.com/vercel/next.js/blob/deprecated-main/examples/with-docker/Dockerfile)

For the option 3 with react I can further optimize it just by copying the build files in neginx and serving from there it required only single server, in case of nextjs do I really need to have node container sering nextjs requests even after build phase ? Like I only want it for frontend do the SSR and SSG

1 Reply

Sun bear
I don't really understand the question. Why would you want to have a reverse proxy on top of vercel?