Nginx 文件列表功能
2022年11月16日小于 1 分钟
Nginx 文件列表功能
模块介绍
有时候我们需要搭建一个文件下载平台,类似镜像站的内容列表,供用户下载,如下所示:

(中国科学技术大学开源镜像站)
该功能用到了 ngx_http_autoindex_module
这个模块,该模块默认是关闭的。
语法:
- 开启文件列表功能:
autoindex on;
可以将它配置在 http
,server
,location
中的任一位置。
配置案例
需要将 /sites/Hello W/download/
目录变成可下载的内容列表,只需配置如下 location
:
server {
listen 80;
server_name www.Hello W.cn;
root /sites/Hello W;
index index.html;
location /download {
autoindex on;
}
}
参考资料
Loading...