Nginx config, Angular production

17 Views Asked by At
**My nginx.conf file**  
  upstream app {
        server localhost:4200;
    }

    server {
        listen 80;
        server_name ****.kz;
        index index.html;
    
        location / {
            try_files $uri $uri/ index.html;
            root /app/dist/sed_sso_frontend;
        }
    
        return 301 https://$host$request_uri;
    }

    server {
        listen 443 ssl;
        server_name ****.kz;
        client_max_body_size 10M;
    
        # SSL Certificate and Key paths
        ssl_certificate /etc/ssl/certs/ssl-bundle.crt;
        ssl_certificate_key /etc/nginx/certs/__onaidocs_kz_key.txt;

    location / {
            try_files $uri $uri/ /dist/sed_sso_frontend/index.html;
    }
    }


**And my Dockerfile**

    FROM node:lts
    
    WORKDIR /app
    
    COPY package*.json ./
    
    RUN npm install -g @angular/cli
    RUN npm install
    
    COPY . .
    
    EXPOSE 4200
    
    CMD ["sh", "-c", "npm run build_prod && tail -f /dev/null"]


what i doing wrong?
I had error like this

rewrite or internal redirection cycle while internally redirecting to "/index.html"

or like this

****"/app/dist/sed_sso_frontend/index.html" is not found (2: No such file or directory), client: ****, server: .kz, request: "GET / HTTP/1.1"

0

There are 0 best solutions below