I’ve been trying to run my angular app on nginx with docker but I can’t get it running. This are the last modifications I tried:
My docker file:
FROM node:latest as build WORKDIR /usr/local/app COPY package.json . COPY . . RUN npm install RUN npm install @angular/cli@17 CMD ["npm", "start"] EXPOSE 4200
My docker-compose.yaml file:
version: "3" services: app: container_name: app build: context: . nginx: container_name: nginx image: nginx ports: - "80:80" depends_on: - app volumes: - ./default.conf:/etc/nginx/conf.d/default.conf
My default.conf file:
server { listen 80; server_name app; location / { proxy_pass http://app: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; } }
The command i’ve been using to run my compose file:
docker-compose up --build
The error I get when trying to connect:
502 Bad Gateway
I couldn’t get through it
user24718521 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.