0

i have a mono-repo angular project with two angular apps and i have copied dist folders like below

COPY dist/app1/ /usr/share/nginx/html
COPY dist/app2/ /usr/share/nginx/html

nginx conf

server {
  listen 8002;
  root /usr/share/nginx/html/app1;
  expires $expires;
  location ~ \.[a-z]*$ {
  }
  location / {
    try_files $uri$args $uri$args/ /index.html =404;
    add_header file-served index;
  }
}
server {
  listen 8003;
  root /usr/share/nginx/html/app2;
  expires $expires;
  location ~ \.[a-z]*$ {
  }
  location / {
    try_files $uri$args $uri$args/ /index.html =404;
    add_header file-served index;
  }
}

But while running docker image I am receiving the error below like this

docker run -p 8020:8002 -p 8021:8003 d6b

[error] 7#7: *1 directory index of "/usr/share/nginx/html/app1/" is forbidden, client: 172.17.0.1, server: , request: "GET / HTTP/1.1", host: "localhost:8020"
[error] 7#7: *2 directory index of "/usr/share/nginx/html/app2/" is forbidden, client: 172.17.0.1, server: , request: "GET / HTTP/1.1", host: "localhost:8021"
Vinoth
  • 23
  • 5
  • can you show the contents of `/usr/share/nginx/html`. – Arslan Sohail Bano Jun 03 '22 at 13:49
  • 2
    The issue is possibly related to `COPY dist/app1/ /usr/share/nginx/html` which does not contain `app1` or `app2` folder, try changing it to `COPY dist/app1/ /usr/share/nginx/html/app1` and same for the app2 and retest it – Arslan Sohail Bano Jun 03 '22 at 13:57
  • I have added my output path of angular like this --output-path="dist/app1/ so have not included path there – Vinoth Jun 03 '22 at 14:04
  • (You might try `docker run --rm d6b ls /usr/share/nginx/html` to see what's in the built image, I think @ArslanSohailBano is right about the `COPY` paths.) – David Maze Jun 03 '22 at 14:11
  • i have the below folders index.html app1 app2 – Vinoth Jun 03 '22 at 14:20
  • then maybe this can help you: https://stackoverflow.com/a/38046124/18232031 – Arslan Sohail Bano Jun 03 '22 at 14:28
  • I don't know where did you get that weird `try_files $uri$args $uri$args/ /index.html =404;` example, using `$args` suffix here is definitely not needed (while this isn't the cause of the error you get). – Ivan Shatsky Jun 03 '22 at 15:47

0 Answers0