I’ve been trying to host an angular app on nginx with docker but when I build the container and go to localhost:8080 I get an 502 Bad Gateway error.
This is my dockerfile:
FROM node:latest as build WORKDIR /usr/local/app COPY ./ /usr/local/app/ RUN npm install RUN npm install -g @angular/cli CMD ["npm", "start"] FROM nginx:latest RUN rm /usr/share/nginx/html/* COPY --from=build /usr/local/app/dist/prueba /usr/share/nginx/html RUN rm etc/nginx/conf.d/default.conf COPY default.conf /etc/nginx/conf.d/ EXPOSE 80
This is my default.conf file:
server { listen 80; server_name app; location / { proxy_pass http://localhost:4200; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } }
This is the line im using to build the image:
docker build -t front .
This is the line im using to run the image:
docker run -d -p 8080:80 front
I don’t know what to do, im going crazy
user24718521 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.