nginx启用了自动目录列表功能的安全漏洞修复方法

一、前言

最近被扫描到安全漏洞,说是nginx启用了自动目录列表功能,现象就是访问http://localhost/file就能看到服务器上的目录

二、修复方法

1.把nginx.conf中的autoindex on改为autoindex off

location /file {
		alias   /myuser/userfile/file;
		autoindex off;
	}

(这个配置映射到了服务器的file目录下,如果是on,就会看到目录,改为off就可以了)

2.重启nginx

sudo nginx -s reload
nginx -s reload

三、备注

Nginx 中默认不会开启目录浏览功能,若您发现当前已开启该功能,可以编辑nginx.conf文件,删除如下两行:autoindex on;autoindex_exact_size on,然后重启Nginx。

猜你喜欢

转载自blog.csdn.net/BHSZZY/article/details/133386941