网站首页 > 技术教程 正文
文章重点讲述nginx静态服务器搭建
ngx_http_autoindex_module
ngx_http_autoindex_module模块处理以斜杠字符('/')结尾的请求,并生成目录列表。当ngx_http_index_module模块找不到index.html文件时,通常会将请求传递给ngx_http_autoindex_module模块。
配置样例:
location / {
root /home/map/www/; #指定目录所在路径
autoindex on; # 打开目录浏览功能
autoindex_exact_size off;# 以可读的方式显示文件大小,单位为 KB、MB 或者 GB,autoindex_format为html格式时有效
autoindex_localtime on; # 以服务器的文件时间作为显示的时间,autoindex_format为html格式时有效
#autoindex_format html; # 以网页的风格展示目录内容。该属性在1.7.9及以上适用
charset utf-8,gbk; # 展示中文文件名
}
autoindex
开启或者关闭列出目录中文件的功能
Syntax: autoindex on | off;
Default: autoindex off;
Context: http, server, location
autoindex_exact_size
对于HTML格式,指定是否应在目录列表中输出精确的文件大小,或者将其舍入为千字节,兆字节和千兆字节
Syntax: autoindex_exact_size on | off;
Default: autoindex_exact_size on;
Context: http, server, location
autoindex_localtime
对于HTML格式,指定是否应该在本地时区或UTC中输出目录列表中的时间。
Syntax: autoindex_localtime on | off;
Default: autoindex_localtime off;
Context: http, server, location
autoindex_format
设置目录列表的格式。
当使用JSONP格式时,使用callback请求参数设置回调函数的名称。如果参数丢失或具有空值,则使用JSON格式。
XML输出可以使用ngx_http_xslt_module模块进行转换。
Syntax: autoindex_format html | xml | json | jsonp;
Default: autoindex_format html;
Context: http, server, location
This directive appeared in version 1.7.9.
Nginx Fancy Index module
在实际体验中ngx_http_autoindex_module模块显示出的界面有点不好看,所以我们可以采用第三的Nginx Fancy Index module模块,该模块提供动态加载,当然也可以编译,这里采用编译安装,替换原有的nginx二进制文件。
如果是动态加载模块需要在events块上面添加:load_module "modules/ngx_http_fancyindex_module.so";
# 查看原有的nginx编译模块
[root@localhost sbin]# ./nginx -V
nginx version: nginx/1.14.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
configure arguments: --prefix=/usr/local/nginx
下载Nginx Fancy Index module 源码包:https://github.com/aperezdc/ngx-fancyindex/archive/v0.4.4.tar.gz
# 编译
./configure --prefix=/usr/local/nginx --add-module=/root/nginx-src/ngx-fancyindex-0.4.4
make
#不能make insatll
备份原本的nginx二进制文件,用新生成的二进制文件做替换,在nginx.conf中添加一下内容, fancyindex就已经启用完成
编辑nginx.conf
location / {
#include /usr/local/nginx/html/Nginx-Fancyindex-Theme/fancyindex.conf;
root django-document/;
#autoindex on;
#autoindex_exact_size off;
fancyindex on; #开启nginx目录浏览功能
fancyindex_exact_size off; #文件大小从KB开始显示
fancyindex_localtime on; #显示文件修改时间为服务器本地时间
#set $limit_rate 1k;
#root html;
#index index.html index.htm;
}
?
此时主题还是略丑,可以下载主题包 git clone https://github.com/lanffy/Nginx-Fancyindex-Theme.git
复制Nginx-Fancyindex-Theme文件到root 文件夹下,在nginx.conf中引入主题包,美化完毕
location / {
include /usr/local/nginx/html/Nginx-Fancyindex-Theme/fancyindex.conf;
root django-document/;
autoindex on;
autoindex_exact_size off;
}
https://www.linuxprobe.com/nginx-autoindex-module.html
猜你喜欢
- 2024-10-10 Nginx之gzip模块(nginx配置gzip压缩)
- 2024-10-10 Nginx源码分析之模块初始化(初始化nginx命令)
- 2024-10-10 Nginx的Gzip模块配置指令(二)(nginx gzip json)
- 2024-10-10 nginx随机模块——ngx_http_random_index_module
- 2024-10-10 写一个Nginx的模块没有那么难(nginx 模块开发)
- 2024-10-10 Nginx模块主要有三种角色(nginx模块主要有三种角色和什么)
- 2024-10-10 后端开发组件,nginx从模块开始,让你对nginx有全新的理解
- 2024-10-10 12、Nginx模块配置应用——模块概述
- 2024-10-10 了解Nginx模块开发与架构,看这一篇就够了,图表齐全通俗易懂
- 2024-10-10 nginx有哪些模块(nginx有哪些功能)
你 发表评论:
欢迎- 最近发表
-
- linux日志文件的管理、备份及日志服务器的搭建
- Linux下挂载windows的共享目录操作方法
- Linux系统中的备份文件命令(linux系统中的备份文件命令有哪些)
- 麒麟KYLINOS|通过不同方法设置用户访问文件及目录权限
- 「Linux笔记」系统目录结构(linux目录的结构及含义)
- linux中修改归属权chown命令和chgrp命令
- 工作日报 2021.10.27 Android-SEAndroid权限问题指南
- Windows和Linux环境下,修改Ollama的模型默认保存路径
- 如何强制用户在 Linux 上下次登录时更改密码?
- 如何删除Linux文件夹中除某些扩展名之外的所有文件?
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)