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 I'm using to build the image:
docker build -t front .
This is the line I'm using to run the image:
docker run -d -p 8080:80 front
I don't know what to do, I'm going crazy.
