ChsXSendfile
鍩轰簬搴旂敤绋嬪簭鐨刪eader鏉ュ彂閫侀潤鎬佹枃浠剁殑鐗规у彨鍋 X-Sendfile.
Lighttpd 鏈夎鐗规,apache涔熸湁涓ā鍧 鍙 mod_xsendfile .
Nginx涔熸湁璇ュ姛鑳,浣嗗疄鐜板緱绋嶅井鏈変簺涓嶅悓.Ngnix璇ュ姛鑳藉彨鍋X-Accel-Redirect.
涓昏鏈変袱涓笉鍚屼箣澶:
- header 蹇呴』鍖呭惈 URI
- location 蹇呴』 琚畾涔変负 internal; 浠ラ樆姝㈠鎴风鐩存帴璁块棶璇 URI
Nginx 閰嶇疆鏍蜂緥:
濡傛灉搴旂敤绋嬪簭杩欎箞鍋氫簡 (浼唬鐮):
add_header("X-Accel-Redirect: /protected/iso.img");
...鐒跺悗nginx灏嗗彂閫佹枃浠 /some/path/protected/iso.img (娉ㄦ剰:root璺緞鍜屽唴閮ㄨ烦杞矾寰勬嫾鎺ュ湪涓璧蜂簡) 缁欏鎴风.
濡傛灉浣犳兂鍙戦佹枃浠 /some/path/iso.img ,閭d箞閰嶇疆鏂囦欢搴旇杩欎箞鍐:
Nginx灏嗕笉鏀瑰彉浠ヤ笅鐨刪eaders淇℃伅:
Content-Type Content-Disposition Accept-Ranges Set-Cookie Cache-Control Expires
濡傛灉鏈缃繖浜沨eader涔嬩竴,瀹冧滑灏嗙敱閲嶅畾鍚戠殑鍝嶅簲璁剧疆.
搴旂敤绋嬪簭鍦ㄥ鐞嗕腑涔熷彲浠ヨ缃湁闄愮殑鎺у埗,鍦 X-Accel-Redirect 涔嬪墠 鍙戦佸涓嬬殑header.
X-Accel-Limit-Rate: 1024 X-Accel-Buffering: yes|no X-Accel-Charset: utf-8
[edit] Links to this issue
Using X-Accel-Redirect Header With Nginx to Implement Controlled Downloads (with rails and php examples) from Alexey Kovyrin