re: Docker 201: Use NGINX as a Reverse Proxy for NodeJS Server in 2020! πŸ“¦ πŸ™Œ (practical guide) VIEW POST


nice article, have you any tips about static files? I've been some problems with css and js front end scripts locations


What worked for me was to create a different folder with nginx and use docker compose in order to run and connect everything at the same time. It works fine in development. Here is the repo I have so far:

Since I just started with docker a couple of weeks ago, I can't get it to work on production though. I can make it work with the static files but I can't find a way to start the express API server.

If someone could lend me a hand I'd appreciate it. Here is how my Dockerfile looks so far:

FROM nginx AS static
COPY ./client /app

FROM node:12-alpine AS api
COPY ./server/package.json /app
RUN npm install
COPY ./server /app

FROM nginx
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=static /app /usr/share/nginx/html

If I remove the middle section (all the node part) it works fine, but as I said I can't find a way to start the express server.

If you user the code in the repo, running docker-compose up --build is going to work fine, as long as you provide your own mongo database of course.

Code of Conduct Report abuse