[SOLVED] Nginx 403 Directory Listing Forbidden

Followed the manual setup guide with nginx. When I try to load the page, I get this in the nginx logs:

2021/12/08 22:59:52 [error] 26350#26350: *1 directory index of “/path/to/neos/” is forbidden, client: 192.168.2.196, server: 127.0.0.1, request: “GET / HTTP/1.1”, host: "192.168.2.27:30080

I’ve redacted the path. The permissions are set to www-data which is what nginx is running as. Flow was set to use these permissions as well.

DirectoryIndex is disabled - that good :slight_smile: But it could seem like you aren’t pointing to the Web folder, where the index.php is located.

And remember the to have rewrite rules like this (depending on how you setup nginx in your case)

location / {
  try_files $uri $uri/ /index.php$is_args$args;
}
1 Like

Ah, the root is not the project folder, it’s the Web folder. Thank you.

1 Like

Nginx 403 Forbidden error is a status code generated and displayed to the user when a client tries to access a part of the webserver with insufficient permissions. When nginx access a directory, it tries to index it and return the list of files inside it to the browser/client, however by default directory indexing is disabled, and so it returns the Nginx 403 forbidden error.

Incorrect Index File

The try_files tries the literal path you specify in relation to the defined root directive and sets the internal file pointer. If you have directory indexing off, and is having this problem, it’s probably because the try_files you are using has a directory option:

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

to

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

Incorrectly set permissions

This error can also result from files and directories having incorrectly set permissions. In order to resolve this , change the directories permission to 755 and the file permissions to 644 . Make sure that the user running the Nginx process owns the files. For example, set user to www-data:

sudo chown -R www-data:www-data *

Finally, set the directory and file permissions as:

sudo chmod 755 {dir}
sudo chmod 644 {files}