nginx如何显示文件夹、nginx如何配置显示目录
发表于:
来源:阿酷技术学习
作者:simplefastbest
有个需求,下载iscroll测试demo显示效果的时候.
它没有一个总入口,我一个一个点击又太费事。就想在nginx中希望能显示目录。我直接点击目录就可以测试。
研究了一下,地址:http://nginx.org/en/docs/http/ngx_http_autoindex_module.html
配置代码:
location / {
autoindex on;
}
指令讲解
autoindex
值:on|off
默认:off
作用域:http|sever|location
autoindex_exact_size
值:on|off
默认:on
作用域:http|sever|location
如果列表项是html,指定文应该精确大小,还是以k,M,G格式显示。on精确大小,off简写
autoindex_format
值:html | xml | json | jsonp
默认:html
作用域:http|sever|location
设置显示格式,默认html,当是jsonp格式,json格式,xml格式,暂时还没有研究。用到时再研究。
autoindex_localtime
值:on | off
默认:off
作用域:http|sever|location
指定显示时间是本地时间还是utc.(Universal Time Coordinated世界标准时间)
我的配置:
location ~ ^/iscroll/ {
root E:/repository;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
charset utf-8,gbk;
}
附一点小知识:查看nginx完整编译参数 nginx -V
nginx -h
nginx version: nginx/1.6.2
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /etc/nginx/)
-c filename : set configuration file (default: /etc/nginx/nginx.conf)
-g directives : set global directives out of configuration file