Nginx基础模块
官方帮助信息
1.Nginx目录索引
http_autoindex_module模块
1.1 语法
默认是不允许列出整个目录浏览下载
syntax: autoindex on
| off
;
Default: autoindex off;
Contxte: http,server,location
1.2 autoindex常用参数
- autoindex_exact_size off; //默认为on,显示出文件的确切大小,单位bytes。 修改为off,显示出文件大概大小,单位是KB或者MB或者GB
- autoindex_localtime on; //默认为off,显示的文件时间为GMT时间。修改为no,显示的文件时间为文件服务器时间
- charset utf-8,gbk; // 默认中文目录乱码,解决乱码
1.3 代码使用方法
server {
listen 80;
server_name localhost;
location / {
root /html;
autoindex on; //开启目录索引
autoindex_exact_size off; //显示出文件的确切大小,单位
charset utf-8,gdk; //默认中文目录乱码,解决乱码。
autoindex_localtime on; //显示的文件时间为文件服务器时间
}
}
[root@nginx_web1 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@nginx_web1 ~]# systemctl restart nginx