nginx配置禁止访问目录但允许访问内部文件

项目的文件通过nginx代理,配置如下:

        location /image/{
                root E:/home/procedure/;
                autoindex on;
                proxy_store on;
        }

通常如此配置即可,访问没有任何问题。但偶然发现这里http://localhost/image/可以访问整个目录,并且可以下载任何该目录下的文件,这是严重的安全漏洞。调整autoindex 配置:

        location /image/{
                root E:/home/procedure/;
                autoindex off;
                proxy_store on;
        }

通过上述配置,完美解决了该问题

猜你喜欢

转载自blog.csdn.net/m0_58709145/article/details/130420395