0

I am trying to dockerizing a angular universal app using nginx, and it's giving me really hard time. I have looked everywhere and haven't found a solution.

Dockerfile

FROM node:14-alpine AS builder
WORKDIR /app
COPY . .
RUN npm i && npm run build:ssr
FROM nginx:alpine
WORKDIR /usr/share/nginx/html
RUN rm -rf ./*
COPY nginx.conf /etc/nginx/nginx.conf
COPY --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"

I have changed localhost:4000 to 127.0.0.1:4000 but still of no use.

0

You must log in to answer this question.

Browse other questions tagged .