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
插件