Quantcast
Channel: Active questions tagged dockerfile - DevOps Stack Exchange
Viewing all articles
Browse latest Browse all 136

Angular universal with docker giving bad gateway

$
0
0

I am trying to dockerizing a angular universal app using nginx, and it's giving me really hard time. It keeps saying 502 bad gateway and I am unable to wrap my head around it.

This is my Dockerfile

FROM node:14-alpine AS builderWORKDIR /appCOPY . .RUN npm i && npm run build:ssrFROM nginx:alpineWORKDIR /usr/share/nginx/htmlRUN rm -rf ./*COPY nginx.conf /etc/nginx/conf.d/default.confCOPY --from=builder /app/dist/front-end-kevi .ENTRYPOINT ["nginx", "-g", "daemon off;"]

In my server.ts file, I am starting the app on port 4000. So I am starting the docker image using this command

docker run -d -p 4000:80 kevin

for the reference, here is my nginx conf file.

server {listen       80;server_name  localhost;root   /usr/share/nginx/html;index  index.html index.htm;location ~* \.(eot|ttf|woff|woff2)$ {add_header Access-Control-Allow-Origin *;}location / {    proxy_pass http://localhost:4000;    try_files $uri $uri/ =404;}location /OrderMationApi/api/v3/ {    proxy_pass http://102.133.225.222;}}

and I am getting this error in error logs

7#7: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.17.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:4000/", host: "localhost:4000"

Any idea where I am doing wrong? Any help is highly appreciated. Thanks in advance.


Viewing all articles
Browse latest Browse all 136

Trending Articles