1. ngx_http_autoindex_module
详情见官网 NGINX
ngx_http_autoindex_module 模块 处理 以 斜线(/)结尾的请求,生成一个目录列表 。通常 当 ngx_http_autoindex_module 模块 找不到 index 文件时 ,请求传递给 ngx_http_autoindex_module 模块处理 。
指令:
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
2. 实践
安装好 nginx 之后 ,修改 nginx 的配置文件 nginx.conf
添加如下 server
server {
listen 84;
location / {
root d:/workspace;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
autoindex_format html;
}
}
开启 nginx : start nginx | nginx
浏览器访问 : localhost:84 即可 索引出 D 盘符下 workspace 目录下的目录。