autoindex : 开启或者禁用 目录列表输出功能

语法: autoindex on | off;
默认: autoindex off;
环境: http, server, location

autoindex_exact_size :对于 HTML 输出格式,指定是否准确的输出文件的大小语法:

autoindex_exact_size on | off;
默认: autoindex_exact_size on;
环境: http, server, location

autoindex_format: 设置目录列表的输出格式

语法: autoindex_format html | xml | json | jsonp;
默认: autoindex_format html;
环境: http, server, location
命令在 1.7.9 版本出现

autoindex_localtime:对于 HTML 输出格式,指定 目录列表中 时间是否以 本地时区显示还是 UTC

语法: autoindex_localtime on | off;
默认: autoindex_localtime off;
环境: http, server, location

查看编译是否有 –with-http_addition_module 参数

例子

server {
	listen 84;
	location / {
		root d:/workspace;
		autoindex on;
		autoindex_exact_size off;
		autoindex_localtime on;
		autoindex_format html;
	}
}

美化

https://github.com/fulicat/autoindex

复制 .autoindex 到相关目录
修改 nginx.conf文件

server {
	listen 80;
	server_name fulicat.bz;
	root D:\websites\fulicat;
	location / {
		index index.html index.htm index.php;
	}


# autoindex for nginx
	location ~ ^(.*)/$ {
		autoindex on;
		autoindex_localtime on;
		autoindex_exact_size off;
		#add_before_body /.autoindex/header.html;
		add_after_body /.autoindex/footer.html;
	}


	location ~ \.php$ {
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		include fastcgi_params;
	}
}