linux – Nginx “directory index is forbidden” error, even though permissions are correctly set
I’m setting up a website with Nginx, and I’m encountering the following error in the logs:
2025/02/17 18:36:50 [crit] 16694#16694: *5 stat() "/var/www/frontend/public/index.html" failed (13: Permission denied), client: 91.245.117.113, server: *ip*, request: "GET / HTTP/1.1", host: "*ip*"
2025/02/17 18:36:50 [error] 16694#16694: *5 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: *ip*, server: *ip*, request: "GET / HTTP/1.1", host: "*ip*"
2025/02/17 19:31:59 [error] 1495#1495: *1 directory index of "/var/www/frontend/public" is forbidden, client: *ip*, server: *ip*, request: "GET / HTTP/1.0"
I have checked and made sure that the necessary permissions are set for the files and directories:
$ ls -l /var/www/frontend/public
-rwxr-xr-x 1 www-data www-data 3870 Feb 17 18:13 favicon.ico
-rwxr-xr-x 1 www-data www-data 602 Feb 17 18:13 index.html
-rwxr-xr-x 1 www-data www-data 5347 Feb 17 18:13 logo192.png
-rwxr-xr-x 1 www-data www-data 9664 Feb 17 18:13 logo512.png
-rwxr-xr-x 1 www-data www-data 492 Feb 17 18:13 manifest.json
-rwxr-xr-x 1 www-data www-data 67 Feb 17 18:13 robots.txt
I have also confirmed that the Nginx configuration is correct and the files should be accessible. Here’s the relevant Nginx configuration:
server {
listen 80;
server_name *server_ip*;
root /var/www/frontend/public;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
}
Despite all the settings, I still receive the “directory index is forbidden” error. Could there be another issue other than file permissions?
Read more here: Source link
