Nginx(openresty) 开启目录浏览 以及进行美化配置

1 nginx 安装 可以参考:Nginx(openresty) 通过lua结合Web前端 实现图片,文件,视频等静态资源 访问权限验证,进行鉴权 ,提高安全性-CSDN博客

2 开启目录浏览

复制代码
location /file
 {
    alias /data/www/; #指定目录所在路径
    autoindex on; #开启目录浏览
    autoindex_format html; #以html风格将目录展示在浏览器中
    autoindex_exact_size off; #切换为 off 后,以友好的方式显示文件大小,单位为 KB、MB 或者 GB
    autoindex_localtime on; #以服务器的文件时间作为显示的时间
    charset utf-8,gbk; #显示中文文件名
 }

3 查看

4 目录浏览美化,采用第三方插件ngx-fancyindex

复制代码
#下载,解压ngx-fancyindex
wget https://github.com/aperezdc/ngx-fancyindex/releases/download/v0.5.2/ngx-fancyindex-0.5.2.tar.xz
tar xvf  ngx-fancyindex-0.5.2.tar.xz

5 nginx 重新编译

复制代码
#编译
./configure --prefix=/usr/local/openresty  --user=www --group=www  --with-http_gzip_static_module --with-threads --with-http_ssl_module --with-http_image_filter_module --with-debug --with-http_stub_status_module --with-openssl=../openssl-1.0.2j --with-http_v2_module --with-stream --add-module=../ngx-fancyindex-0.5.2
make
#备份和升级
mv /usr/local/openresty/nginx/sbin/nginx /usr/local/openresty/nginx/sbin/nginx_0530
cp  ./build/nginx-1.1.9/objs/nginx  /usr/local/openresty/nginx/sbin/

6 下载Nginx-Fancyindex-Theme主题

主题下载

复制代码
#下载,解压
ll /usr/local/openresty/nginx/html/Nginx-Fancyindex-Theme-light/
total 216
-rw-r--r-- 1 root root  1088 Jan 12  2021 addNginxFancyIndexForm.js
-rw-r--r-- 1 root root   688 Jan 12  2021 fancyindex.conf
-rw-r--r-- 1 root root  1982 Jan 12  2021 footer.html
-rw-r--r-- 1 root root   707 Jan 12  2021 header.html
-rw-r--r-- 1 root root   114 Jan 12  2021 HEADER.md
-rw-r--r-- 1 root root 83667 Jan 12  2021 jquery.min.js
-rw-r--r-- 1 root root   117 Jan 12  2021 README.md
-rw-r--r-- 1 root root 99095 Jan 12  2021 showdown.min.js
-rw-r--r-- 1 root root  4417 Jan 12  2021 styles.css

7 nginx 配置修改

复制代码
location /file
{
    include /usr/local/openresty/nginx/html/Nginx-Fancyindex-Theme-light/fancyindex.conf;
    alias /data/logs/online/log/; #指定目录所在路径
    charset utf-8,gbk; #显示中文文件名
}

#效果如下

相关推荐
Agome9935 分钟前
Docker之nginx安装
java·nginx·docker
向日葵花籽儿37 分钟前
#运维 | 前端 # Linux http.server 实践:隐藏长文件名,简短路径 (http://IP:port/别名 ) 访问
linux·运维·前端
安全漏洞防治中心2 小时前
Roadmap:一年实现安全漏洞防治自动化
运维·web安全·网络安全·自动化·漏洞管理·漏洞处置sop·漏洞紧急修复建议
努力买辣条5 小时前
基于Docker的高可用WordPress集群部署:Nginx负载均衡+Mysql主从复制+ProxySQL读写分离
nginx·docker·负载均衡
我一定会有钱8 小时前
Linux爆音问题解决方法(隔一会会有奇怪噪音)
linux·运维·服务器
Dobby_0511 小时前
【Ansible】变量与敏感数据管理:Vault加密与Facts采集详解
linux·运维·云原生·ansible
记忆不曾留11 小时前
unbuntu 20.04 docker 部署wordpress
运维·docker·容器·wordpress·独立站建站
zcz160712782111 小时前
服务器与客户端
运维·服务器
xx.ii12 小时前
28.Linux :通过源代码编译安装lamp
linux·运维·服务器
焊锡与代码齐飞12 小时前
嵌入式第三十五课!!Linux下的网络编程
linux·运维·服务器·开发语言·网络·学习·算法