#有server name匹配。IP也行
server {
listen 443;
server_name passport-lnxtfz.e.lanxin.cn;
charset utf-8;
ssl on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /home/s/apps/openresty/nginx/conf/conf.d/lx-crt;
ssl_certificate_key /home/s/apps/openresty/nginx/conf/conf.d/lx-key;
ssl_session_timeout 30m;
access_log /home/s/logs/openresty/passport.access.log;
error_log /home/s/logs/openresty/passport.error.log;
##完整的数据路径应该是:/data/lanxin/download/lanxin
#/data/download 这个目录下面 还要有个lanxin的目录,但是写root的时候,配置不用写出来而已
#lias 和 root的区别有点类似于一个绝对路径和一个相对路径,alias指定什么就是什么,root执行的目录下面 #必须有localtion匹配的目录才行
location /lanxin {
root /data/lanxin/download;
autoindex on;
}
这样设置后,就会展示成列表:
但是这样展示有一个问题:
当这个目录很长的时候,有时候我们上传一个文件时,我们希望这个文件显示在最顶端。而Nginx默认是以文件名排序的。不支持时间倒序排列,怎么办呢?
到网上查了下,需要使用一个第三方Nginx库来支持:FancyIndex。
具体安装方法:
1、下载FancyIndex包:https://codeload.github.com/aperezdc/ngx-fancyindex/zip/master
2、将下载的zip包解压到nginx源码目录。
3、重新编辑安装Nginx:
# ./configure --prefix=/usr/local/nginx --add-module=./ ngx-fancyindex-master
# make
# make install
4、重新安装后,需要如果之前已经运行Nginx,需要将Nginx停掉后,重新启动,注意,不能用reload。:/usr/local/nginx/sbin/nginx -s stop&& /usr/local/nginx/sbin/nginx
5、下载fancyindex资源文件:https://github.com/TheInsomniac/Nginx-Fancyindex-Theme
6、下载后,解压到文件根目录:
7、配置Nginx配置文件,在location或者server中添加以下代码:
8、重启Nginx,看下效果吧~啦啦啦~~~~
是不是展示好了很多?其中fancyindex_default_sortdate_desc;就是以上传时间倒序排列的