#有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;就是以上傳時間倒序排列的