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