nginx 报错:Nginx 403 error:directory index of “xxx“ is forbidden

在部署好Nginx服务器后,输入IP地址和端口号,返回403 Forbiddent

查看日志error.log,发现报错信息为:

 

 

directory index of "xxx" is forbidden

其中,xxx是在/etc/nginx/nginx.conf中指定的root目录。

报错根因:直接使用IP地址和端口号访问时,需要指定index,如果未指定,出现该报错。

这时候,可以在nginx/nginx.conf中添加配置:
autoindex on; # 自动索引

 

 

这样再次访问的时候,就会列出所有的资源索引。

 

 【注意】修改nginx.conf后,记得重启服务才能生效。

 

posted @ 2021-10-14 14:48  奔跑中的兔子  阅读(4788)  评论(1编辑  收藏  举报