douli2876
2016-08-23 06:07
浏览 74
已采纳

使用nginx加速标头重定向

Is it possible to download a remote file using nginx accel headers? I'm getting file not found in Firefox and invalid response in Chrome.

header("Content-Disposition: attachment; filename= 'asd.zip'");
header("Content-Type: application/octet-stream");
header('X-Accel-Redirect: http://subdomain.samedomain.com/upload/files/qwe.zip');
header("X-Accel-Buffering: yes");
header("X-Accel-Limit-Rate: 102400");

图片转代码服务由CSDN问答提供 功能建议

是否可以使用nginx accel标题下载远程文件? 我在Firefox中找不到文件,Chrome中的响应无效。

  header(“Content-Disposition:attachment; filename ='asd.zip'”); 
header  (“Content-Type:application / octet-stream”); 
header('X-Accel-Redirect:http://subdomain.samedomain.com/upload/files/qwe.zip');
header("X- 加速缓冲:是“); 
header(”X-Accel-Limit-Rate:102400“); 
   
 
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dsjq6977 2016-08-23 06:33
    已采纳

    You have to use a proxy_pass to proxy to the remote server. Example:

    header("Content-Disposition: attachment; filename= 'asd.zip'");
    header("Content-Type: application/octet-stream");
    header('X-Accel-Redirect: /upload/domain.com/path/to/file.zip');
    header("X-Accel-Buffering: yes");
    header("X-Accel-Limit-Rate: 102400");
    

    Nginx

    location ~* ^/upload/(.*?)/(.*) {
        internal;
        set $download_host  $1; 
        set $download_uri   $2; 
        proxy_pass http://$download_host/$download_uri;
    }
    
    已采纳该答案
    打赏 评论

相关推荐 更多相似问题