Nginx使用(二)

nginx

# 使用目录浏览功能(autoindex)

启用目录浏览访问,nginx默认没有开启该功能,要开启则要在server或local代码块中添加 autoindex on;

参数说明:

属性名 属性值
autoindex 默认为off不开启。on为开启
autoindex_exact_size 默认为on,显示出文件的确切大小,单位是bytes。
改为off后,显示出文件的大概大小,单位是kB或者MB或者GB
autoindex_localtime 默认off,文件时间为GMT时间;
on,文件显示时间为服务器时间;

修改 /etc/local/nginx/conf/nginx.conf文件

server新增location指令块

  ##虚拟目录开启目录流量 指定到/app/down/目录下
  location /downs/ {
                alias /app/down/;
                #目录显示文件
                autoindex on;
                #off 显示kb,mb,gb
                autoindex_exact_size off;
                #服务器时间
                autoindex_localtime on;

  }

1
2
3
4
5
6
7
8
9
10
11
12

image-20210421140919170

查看nginx中指向的目录下

image-20210825102107902

启动nginx

#进入 /etc/local/nginx/sbin/

#启动或重启nginx
./nginx  或者  ./nginx -s reload
1
2
3
4

访问配置的url

image-20210825102507304

注意: alias目录必须要以 / 结尾且alias只能在location中使用;

更新时间: 2 分钟前