nginx 使用 fancyindex 目录索引

马谦马谦马谦 nginx评论2,181字数 828阅读 2 分 45 秒阅读模式

一、 nginx 目录索引

nginx 中内置了目录索引命令 auto_index ,十分方便就能给目录生成 web 索引:

效果如下:

nginx使用fancyindex目录索引-图片1

两个可选的命令是 autoindex_exact_sizeautoindex_localtime ,分别表示是否精确显示文件大小 (以字节方式) 和是否显示本地时间,两个都 不开启 的情况下是这样的:

二、使用 fancyindex 索引

nginx 自带的索引功能很单一,界面也很原始。后面有人做了个 fancyindex 的插件用来强化这个功能,已经被官方采用。官方文档地址,fancyindex 代码地址:ngx-fancyindex

2.1 编译 fancyindex

安装 fancyindex 要重新编译 nginx,首先下载 fancyindex 源码

解压 nginx 进入目录,重新执行 configure 命令,指定参数 --add-module 添加 fancyindex 模块,nginx 安装的具体流程可以参考源码编译安装 nginx

执行 make 和 make install 即可完成安装。

2.2 使用 fancyindex

fancyindex 的指令:

其效果如下:

nginx使用fancyindex目录索引-图片2

点击表头的 File NameFile Size 或者 Date 能对文件进行排序。

2.3 其他用法

fancyindex 提供了自定义页头和页脚,分别通过指令 fancyindex_headerfancyindex_footer 完成。例如在页脚加上一个超链接到百度首页:

然后在 网站根目录下 加上一个 fancy_footer.html

重新载入后的页面:

nginx使用fancyindex目录索引-图片3

 
马谦马谦马谦
  • 本文由 马谦马谦马谦 发表于 2018 年 9 月 2 日 22:24:35
  • 转载请务必保留本文链接:https://www.dyxmq.cn/it/nginx/nginx-fancyindex.html
Nginx-ModSecurity使用Comodo WAF规则 nginx

Nginx-ModSecurity 使用 Comodo WAF 规则

一、概述 之前安装好了 ModSecurity 作为 nginx 的 WAF,但是后续的使用中发现 OWASP-CRS 规则过于苛刻,很多正常操作都会被阻挡,甚至打开一个正常的页面都会被拦截。每次都要手动排除规则十...
nginx中的if和else语法 nginx

nginx 中的 if 和 else 语法

nginx 支持 if 语法,语法和平常的代码格式差不多: if ($xxx = xxx) { xxx } 只是和代码不同的是,if 条件语句判断相等只要一个等号,不是==。 nginx 虽然有 if,但是却不支...
nginx配置php-fpm和php通信 nginx

nginx 配置 php-fpm 和 php 通信

一、概述 php-fpm 是一种通信方式,使得 nginx 可以通过 cgi 和 php 之间快速通信。 nginx 的提供了一份默认的 php-fpm 的配置: #location ~ \.php$ { # root h...
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证
加载中...