nginx: http_autoindex_module

陪她去流浪 桃子 2015年04月17日 阅读次数:2607

ngx_http_autoindex_module处理那些以斜杠(‘/’)结尾的请求(目录访问)并产生对该目录的文件枚举。

通常某个请求会在 ngx_http_index_module 模块无法找到该目录的索引(index)文件的时候才会传递给 ngx_http_autoindex_module 模块继续处理。

注:通常以这种方式来实现只可以下载文件的文件服务器(匿名只读FTP服务器)。

产生的结果类似下面这样:

Index of /share/

../ test.txt 14-Dec-2014 18:50 293 v.txt 13-Jan-2015 14:31 49

示例配置

location / {
    autoindex on;
}

指令

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

启用或禁止目录枚举。

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

对于 HTML 格式输出时,指定是输出文件的精确大小还是更易于阅读的方式(KB/MB/GB)。

语法autoindex_format html | xml | json | jsonp;
默认autoindex_format html;
环境http, server, location
版本1.7.9

设置目录枚举的输出方式。

在使用 JSONP 格式时,需要在回调请求参数中设置回调函数的名字。如果未设置该参数(或为空),则使用 JSON。

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

对于 HTML 格式输出,指定时间显示方式:本地时间 或 UTC(调整世界时)。

这篇文章的内容已被作者标记为“过时”/“需要更新”/“不具参考意义”。

标签:nginx