Nginx 下载应用配置
Nginx •
•
581次阅读
location /download {
# 请求download的路径
alias /data/upload
types { }
# 设置当前目录所有文件默认MIME类型 application/octet-stream
default_type application/octet-stream;
# 文件不存在时,跳转
try_files $uri @nofile;
# 开启零复制文件传输功能
sendfile on;
# 每个sendfile调用的最大传输量为1MB
sendfile_max_chunk 1M;
# 启用最小传输限制功能
tcp_nopush on;
# 启用异步传输
aio on;
# 当文件大于5mb时以这一集读取磁盘方式读取文件
directio 5M;
# 与磁盘的文件系统对齐
directio_alignment 4096;
# 文件输出的缓冲区为128kb
output_buffers 4 32k;
# 限制下载速度1MB
limit_rate 1m;
# 当客户端下载速度达到2MB时,进入限速模式
limit_rate_after 2m;
# 客户端执行范围读取的最大值时4096B
max_ranges 4096;
# 客户端引发传输超时间为20s
send_timeout 20s;
# 当缓冲区的数据达到2048B时再向客户端发送
postpone_output 2048;
# 启用分块传输标识
chunked_transfer_encoding on;
}
location @nofile {
index nofile.html
}
location = /404.html {
internal;
}
好的生活就是不瞎想,做得多,要得少,常微笑,懂知足。