配置 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/


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM