php+nginx做下载服务器配置

来源:互联网 发布:rsync指定ssh端口 编辑:程序博客网 时间:2024/05/22 10:37

nginx配置文档

location /down{    internal;    alias /home/www/filespath;}

/* 此段是为了防止直接通过地址访问文件而做,可以作为防盗链*/

location /filepath{    internall;}

php文件设置:

$filepath = '2011/12/31/abcd.zip';$filename = 'abcd.zip';header("Content-Disposition: attachment; filename= '{$filename}'");header("Content-Type: application/octet-stream");header('X-Accel-Redirect: /down/'.{$filepath}); header("X-Accel-Buffering: yes");header("X-Accel-Limit-Rate :102400"); //速度限制 Byte/s//header("Accept-Ranges: none");//单线程 限制多线程

在使用时候,必须要明白以下头信息是不能被Nginx更改的(即这些信息得由你来指定!)

Content-TypeContent-DispositionAccept-RangesSet-CookieCache-ControlExpires

如果其中的一些信息没有指定,那么重定向请求设置!
4.更多处理控制
你可以通过一下头信息来配置 X-Accel-Redirect 特性:

X-Accel-Limit-Rate: 1024X-Accel-Buffering: yes|noX-Accel-Charset: utf-8
0 0
原创粉丝点击