利用nginx+fancyindex美化目录索引

简介: 利用nginx+fancyindex美化目录索引1.下载第三方插件

利用nginx+fancyindex美化目录索引

1.下载第三方插件

1)下载插件
[root@localhost ~]# wget -O fancyindex.zip https://github.com/aperezdc/ngx-fancyindex/archive/v0.4.3.zip
[root@localhost ~]# wget -O fancytheme.zip https://github.com/Naereen/Nginx-Fancyindex-Theme/archive/master.zip
2)解压
[root@localhost ~]# unzip fancyindex.zip
[root@localhost ~]# unzip fancytheme.zip

2.重新编译nginx

[root@localhost ~]# tar -zxvf nginx-1.16.0.tar.gz
[root@localhost ~]# cd nginx-1.16.0
[root@localhost ~]# ./configure --prefix=/data1/nginx --add-module=/root/ngx-fancyindex-0.4.3/ --user=root --group=root && make && make

3.准备目录索引路径

[root@localhost ~]# mkdir /data1/www/html/repo/{centos6.5,centos7.5,tomcat,fio,redis,elasticsearch,abase} -p

4.编写站点配置文件

conf.d目录需要手动创建,然后再主配置文件nginx.conf中配置一个include才能识别其他路径的配置文件

1.1.创建配置文件路径
[root@localhost ~]# mkdir /data1/nginx/conf/conf.d/
2.修改主配置文件
[root@localhost ~]# vim /data1/nginx/conf/nginx.conf
http {
    ......
    include  /data/nginx/conf/conf.d/*.conf
    ......
 }    
3.编写目录索引配置文件
[root@localhost ~]# cd /data1/nginx/conf/conf.d/
[root@localhost conf.d]# vim repo.conf
server {
  listen 888;
  server_name localhost;
  location / {
    fancyindex on;
    fancyindex_localtime on;
    fancyindex_exact_size off;
    fancyindex_footer "/data/www/html/Nginx-Fancyindex-Theme-dark/footer.html";
    fancyindex_header "/data/www/html/Nginx-Fancyindex-Theme-dark/header.html";
    root /data1/www/html;
    charset utf-8,gbk;
  }
}

5.将fancyindex放到站点目录

[root@localhost ~]# mv /root/Nginx-Fancyindex-Theme-master/fancyindex.conf /data1/nginx/conf/
[root@localhost ~]# mv /root/Nginx-Fancyindex-Theme-master/Nginx-Fancyindex-Theme-dark/ /data1/www/html/
将站点标题改成自己的称谓
[root@localhost ~]# vim /data/www/html/Nginx-Fancyindex-Theme-dark/header.html
修改最后一行即可
<h1>jiangxl_20200714

6.启动nginx

[root@localhost ~]# nginx -t
[root@localhost ~]# nginx

7.访问

访问http://192.1.44.123:888/repoimage.png

目录
相关文章
|
2月前
|
存储 应用服务中间件 nginx
nginx反向代理bucket目录配置
该配置实现通过Nginx代理访问阿里云OSS存储桶中的图片资源。当用户访问代理域名下的图片URL(如 `http://代理域名/123.png`)时,Nginx会将请求转发到指定的OSS存储桶地址,并重写路径为 `/prod/files/2024/12/12/123.png`。
100 5
|
6月前
|
JavaScript 应用服务中间件 PHP
nginx server 禁止特定目录下的某类文件访问
【8月更文挑战第26天】这段Nginx配置代码旨在保护`/uploads/`目录下的文件,禁止执行任何`.php`, `.html`, `.htm`, 或 `.js`等潜在有害文件,即便被访问也无法运行。取而代之的是重定向到首页。为了实现这一设置,用户需要定位到对应子域名的`.conf`配置文件中进行相应修改。若网站支持多个访问域名,则需确保在正确的`.conf`文件中实施此配置。
135 1
|
6月前
|
应用服务中间件 Linux nginx
【Azure 应用服务】App Service For Container 配置Nginx,设置/home/site/wwwroot/目录为启动目录,并配置反向代理
【Azure 应用服务】App Service For Container 配置Nginx,设置/home/site/wwwroot/目录为启动目录,并配置反向代理
|
7月前
|
Ubuntu 应用服务中间件 Linux
Linux学习之Ubuntu 20中OpenResty的nginx目录里内容和配置文件
总的来说,OpenResty的Nginx配置文件是一个强大的工具,它允许你以非常灵活的方式定义你的Web服务的行为。
148 2
|
7月前
|
应用服务中间件 nginx
如何通过Nginx配置将请求转发到conf.d目录下的各个配置文件
如何通过Nginx配置将请求转发到conf.d目录下的各个配置文件
756 2
|
7月前
|
应用服务中间件 nginx
Ngnix07---通过yum安装Ngnix下 whereis ngnix可以查看Ngnix相关的一些目录,使用./nginx -y可以查看Ngnix版本及相关配置信息,使用 more CHANGES
Ngnix07---通过yum安装Ngnix下 whereis ngnix可以查看Ngnix相关的一些目录,使用./nginx -y可以查看Ngnix版本及相关配置信息,使用 more CHANGES
|
7月前
|
应用服务中间件 开发工具 nginx
Ngnix09目录结构分析,使用tree工具可以Ngnix目录中以一个树的方式呈现出来,yum install -y tree,tail -f nginx/logs/access.log
Ngnix09目录结构分析,使用tree工具可以Ngnix目录中以一个树的方式呈现出来,yum install -y tree,tail -f nginx/logs/access.log
|
9月前
|
Ubuntu 应用服务中间件 Linux
蓝易云 - Linux学习之Ubuntu20中OpenResty的nginx目录里内容和配置文件
你可以根据你的需要修改这个配置文件,例如增加新的服务器块,位置块,修改监听的端口等。修改完配置文件后,你需要重载Nginx配置,可以使用 `/usr/local/openresty/nginx/sbin/nginx -s reload`命令来实现。
99 0
|
运维 监控 网络协议
【运维知识进阶篇】集群架构-Nginx常用模块(目录索引+状态监控+访问控制+访问限制)(下)
【运维知识进阶篇】集群架构-Nginx常用模块(目录索引+状态监控+访问控制+访问限制)(下)
107 0