0
点赞
收藏
分享

微信扫一扫

使用nginx作为下载服务器时,通过autoindex设置自动索引,limit_rate控制下载速度

西特张 2024-11-04 阅读 2
nginx运维
  • autoindex on | off;#自动文件索引功能,默为off
  • autoindex_exact_size on | off; #计算文件确切大小(单位bytes),off 显示大概大小(单位K、M),默认on
  • autoindex_localtime on | off ; #显示本机时间而非GMT(格林威治)时间,默认off
  • autoindex_format html | xml | json | jsonp; #显示索引的页面文件风格,默认html
  • limit_rate rate; #限制响应客户端传输速率(除GET和HEAD以外的所有方法),单位B/s

配置一个下载站点

[root@localhost conf.d]# mkdir /data/nginx/html/uhn/software
[root@localhost conf.d]# vi uhn.conf 

server {
   listen 80;
   server_name www.uhn.cn;

   error_page 500 502 503 504  /error.html;
   location = /error.html {
   root /data/nginx/html/uhn;
   }

   location / {
   root /data/nginx/html/uhn;
   try_files $uri $uri.html $uri/index.html =911;
#   auth_basic "login password";
#   auth_basic_user_file /software/nginx/conf/.htpasswd;
   }


   location /software {
   root /data/nginx/html/uhn;
   autoindex on;
   autoindex_exact_size on;
   autoindex_localtime on; 
   limit_rate 1024k;
   }
}

上传文件

[root@localhost conf.d]# cd /data/nginx/html/uhn/software

[root@localhost software]# dd if=/dev/zero of=./test.iso bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 0.345383 s, 304 MB/s
[root@localhost software]# 

访问测试

使用nginx作为下载服务器时,通过autoindex设置自动索引,limit_rate控制下载速度_nginx


举报

相关推荐

0 条评论