Nginx,显示文件夹树,虚拟主机

Nginx, show the folder tree, virtualhost

我想显示数据文件夹中的文件夹树,其中包含我安装的 CMS 的日志。 这是我的数据文件 /etc/nginx/sites-available/

server{
        listen 80;
#       listen *:80;
        server_name datas.test.nx;
        location / {
                root /opt/datas/logs;
        }
}

但是当我进入 datas.test.nx 时出现错误 403 Forbidden。我试图显示一个 index.html 我放入 /home/user/index.html 并且它有效,但是当我想显示 datas/logs 的文件夹树时我有这个错误。 我把 chmod 777 放在我所有的文件夹 /datas/* 和一个 chown www-data:www-data /datas/* 上。 你知道吗?谢谢。

您需要启用目录列表。 https://nginx.org/en/docs/http/ngx_http_autoindex_module.html

server{
    listen 80;
    server_name datas.test.nx;
    root /opt/datas/logs;
    location / {
         autoindex on;
    }
}