Fork me on GitHub

配置 Nginx 的目录浏览功能

Nginx 默认是不允许列出整个目录的,需要配置 Nginx 自带的 ngx_http_autoindex_module 模块实现目录浏览功能 。

location / {
    alias /opt/files/;
    
    autoindex on;
    autoindex_exact_size off;
    autoindex_localtime on;
}

autoindex_exact_size off;
默认为on,显示出文件的确切大小,单位是bytes。
改为off后,显示出文件的大概大小,单位是kB或者MB或者GB

autoindex_localtime on;
默认为off,显示的文件时间为GMT时间。
改为on后,显示的文件时间为文件的服务器时间

备注:发现另外一种方案 https://github.com/filebrowser/filebrowser 实现,使用 docker 简单除暴 (docker pull filebrowser/filebrowser) 。

REFER:
http://nginx.org/en/docs/http/ngx_http_autoindex_module.html
http://www.swiftyper.com/2016/12/08/nginx-autoindex-configuration/

posted @ 2018-06-18 11:46  花儿笑弯了腰  阅读(1575)  评论(0编辑  收藏  举报