开启nginx目录文件列表显示功能

正常访问nginx的时,显示nginx欢迎页,也就是我们目录首页(/nginx/html/index.html文件),不会显示项目目录列表,这对于本人代码也起到一定的保护作用;

但我们在开发阶段为了快速浏览列表,可设置目录列表的【显示】

那么重要的时刻到了-----nginx.conf主配置文件中http或location代码段中,配置一段代码即可实现:

http {

		include       mime.types;

		default_type  application/octet-stream;

		autoindex on;  

		autoindex_exact_size off; 

		autoindex_localtime on;
	}

[参数说明]

1、autoindex on;  # 自动显示目录
2、autoindex_exact_size off;
     [
        默认为on,显示出文件的确切大小,单位是bytes
改为off后,显示出文件的大概大小,单位是kB或者MB或者GB
    ]
3、autoindex_localtime on;
    [
默认为off,显示的文件时间为GMT时间。
改为on后,显示的文件时间为文件的服务器时间
    ]