ngx_http_autoindex_module 此模塊用於自動生成目錄列表,ngx_http_autoindex_module只在 ngx_http_index_module模塊未找到索引文件時發出請求.
nginx默認是不允許列出整個目錄的。
開啟目錄列表:
打開nginx.conf文件,在location server 或 http段中加入 autoindex on;
另外兩個參數最好也加上去:
autoindex_exact_size off;
默認為on,顯示出文件的確切大小,單位是bytes。
改為off后,顯示出文件的大概大小,單位是kB或者MB或者GB
autoindex_localtime on;
默認為off,顯示的文件時間為GMT時間。
改為on后,顯示的文件時間為文件的服務器時間
http { include mime.types; default_type application/octet-stream; autoindex on; #自動顯示目錄 autoindex_exact_size off; #人性化方式顯示文件大小否則以byte顯示 autoindex_localtime on; #按服務器時間顯示,否則以gmt時間顯示 server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; limit_zone one $binary_remote_addr 32k; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; log_format wwwlogs '$remote_addr - $remote_user [$time_local] $request$status$body_bytes_sent$http_referer$http_user_agent$http_x_forwarded_for'; #include default.conf; include vhost/*.conf; }
配置Nginx目錄列表的方法詳細參照:http://wiki.nginx.org/NginxChsHttpAutoindexModule
如果想希望目錄列表支持header,footer則可以安裝三方插件: http://wiki.nginx.org/NginxNgxFancyIndex