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/