開啓Nginx的目錄文件列表功能

ngx_http_autoindex_module  此模塊用於自動生成目錄列表,ngx_http_autoindex_module只在 ngx_http_index_module模塊未找到索引文件時發出請求.nginx

nginx默認是不容許列出整個目錄的。shell

開啓目錄列表:
打開nginx.conf文件,在location server 或 http段中加入
 autoindex on;服務器

 autoindex on;//自動顯示目錄
 autoindex_exact_size off;//人性化方式顯示文件大小不然以byte顯示
 autoindex_localtime on;//按服務器時間顯示,不然以gmt時間顯示

另外兩個參數最好也加上去:
autoindex_exact_size off;
默認爲on,顯示出文件的確切大小,單位是bytes。
改成off後,顯示出文件的大概大小,單位是kB或者MB或者GB
autoindex_localtime on;
默認爲off,顯示的文件時間爲GMT時間。
 改成on後,顯示的文件時間爲文件的服務器時間spa

 location /static/ {
           alias   /home/orion/nginx/static/;
           autoindex  on;
           autoindex_exact_size  off;
           autoindex_localtime on;
        }

若是想但願目錄列表支持header,footer則能夠安裝三方插件: http://wiki.nginx.org/NginxNgxFancyIndex
插件

相關文章
相關標籤/搜索