首页 > 解决方案 > 403 尝试列出 Nginx 目录时

问题描述

我正在尝试使用 nginx 和 fancyindex 来托管具有样式的目录。但是,当我尝试查看目录时,出现 403 错误。我可以查看文件(如果存在),而不是没有 index.html 的目录(如果确实有 index.html,则显示该文件而不是目录)。

我检查了目录的权限,目录及其所有内容都是 777。用户是 root(因为它是从 docker 容器托管的,特别是 image byjg/nginx-extras)。

我在做什么错才能得到 403 错误?

我的默认.conf:

server {
    listen 80 default_server;
    root /var/www/html;
    index index.html;
    server_name web.example.com;
    autoindex on;
    location / {
        #try_files $uri $uri/ =404;
        allow all;
        autoindex on;
        fancyindex on;
        fancyindex_localtime on;
        fancyindex_exact_size off;
        fancyindex_header "/theme/header.html";
        fancyindex_footer "/theme/footer.html";
        fancyindex_ignore "theme";
        fancyindex_name_length 255; # Maximum file name length in bytes, change as you like.
    }
}

标签: nginx

解决方案


推荐阅读