0

I'm trying the setup NGINX to access angular /dist folder but can't make it works despite chmod -R 755 /path/to/dist ...

in my NGINX http block:

server {
  listen 80;
  server_name dashboard.example.local;

  ssl off;

  gzip on;
  root /path/to/dist/;
  index index.html;

  location /api/ {
    proxy_pass http://127.0.0.1:3000/;
  }
}

I'm still getting this error "dist/index.html" is forbidden (13: Permission denied)

I already tried all the existing solutions I found on the internet.

EDIT: files that nginx are trying to access are 755

Pierre Clocher
  • 1,067
  • 1
  • 9
  • 21

2 Answers2

1

The problem was in fact Mac OS related. To allow NGINX manipulate local files, we need to tell him to act as your user.

In top of the NGINX template, just put user <your-user-name> staff;

Pierre Clocher
  • 1,067
  • 1
  • 9
  • 21
0

Already compiled angular source served as file it will send to the browser to be renderer (client side). that proxy pass function will only works on development, i assume you run it using angular cli ng serve. this might what you looking for on production or dist folder.

server{
    ...
    root /path/to/dist

    index index.html index.htm index.nginx-debian.html;

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

if the permission still denied try change that folder owner into nginx user with chown command..