admin管理员组

文章数量:1122846

I am facing a issue since a few days. Any help to solve this would be awesome !

I have an angular application, that I want to host on EC2 instance. All other way are blocked by security, can't go with S3 static website.

I have a docker file to prep all:

`
### STAGE 1: Build ###
FROM node:22.5.1-alpine3.20 AS build
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN npm run build
### STAGE 2: Run ###
FROM nginx:latest
COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=build /usr/src/app/dist/front-app/browser /usr/share/nginx/html
`

and nginx.conf file :

`
http {
    include /etc/nginx/mime.types;
    server {
        listen 80;
        server_name localhost;
        root /usr/share/nginx/html;
        index index.html;
        location / {
            try_files $uri $uri/ /index.html;
        }
    }
}

`

after runing docker:

docker sudo docker build -t fe-app .
sudo docker run -d -p 80:80 fe-app

I reached the page but only index.html was served... I get 404 for all other static files

any idea about what could block those files to be found ? I went on the docker to check the folder /usr/share/nginx/html, all files are here

Thanks

Tried without docker, same result

Tried with apache instead of nginx, same result

Tried from files hosted on S3 bucket, same result
Working on my laptop in local from npm run start

本文标签: amazon web servicesAngularnginx on Docker and EC2 does not serve other than indexhtmlStack Overflow