こんにちは、ユーザーが nginx PHP で構成されたサーバー (Windows) から PDF ファイルをダウンロードできるようにしたいと考えています。これは私のnginx.conf(サーバーブロック)です
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile      on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        location / {
            root   html;
            index  index.php;
        }
         location /download {
            internal;
            alias /protected;
        }
    }
}
..そしてPHPファイル(ヘッダー部分)
$file = '/download/real-pdf-file.pdf'; //this is the physical file path
$filename = 'user-pdf-file.pdf'; //this is the file name user will get
header('Cache-Control: public, must-revalidate');
header('Pragma: no-cache');
header('Content-Type: application\pdf');
header('Content-Length: ' .(string)(filesize($file)) );
header('Content-Disposition: attachment; filename='.$filename.'');
header('Content-Transfer-Encoding: binary');
header('X-Accel-Redirect: '. $file);
ファイルは次のような URL から呼び出されます。
download.php?id=a2a9ca5bd4a84294b421fdd9ef5e438ded7fcb09
ここからいくつかの例/解決策を試しましたが、これまでのところ何も機能していません。ファイルは大きく (それぞれ 250 から 400 MB)、各ユーザーは 4 つのファイルをダウンロードできます。
PHP を使用して一部をダウンロードしても問題はありませんが、動作していないように見える nginx 構成のみです。エラー ログは検出されませんでした。