2016-08-23 6 views
0

nginx accelヘッダーを使用してリモートファイルをダウンロードすることはできますか? Firefoxでファイルが見つからず、Chromeで無効な応答が表示されています。nginx accelヘッダーでリダイレクト

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"); 

答えて

0

リモートサーバーへのプロキシにはproxy_passを使用する必要があります。例:

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; 
} 
+0

リモートサーバがホストを取得するために、動的 – slash197

+0

使用正規表現です。 –

関連する問題