簡體   English   中英

X-Accel-Redirect 的內部重定向別名錯誤

[英]Wrong internal redirect alias for X-Accel-Redirect

Nginx 內部重定向文件搜索路徑錯誤。

我正在使用 nginx 和 laravel(PHP) 並且想要進行安全的在線存儲。如果用戶存在並且有權限,用戶可以下載文件。 我為此操作使用“X-Accel-Redirect”。

    //it works with apache X-Sendfile
    public function download()
    {
        $filename = "4.jpg";
        return response(null)
            ->header('Content-Disposition', 'attachment; filename="' . $filename . '"')
            ->header('X-Accel-Redirect', "/storage/app/public/$filename")
            ->header('X-Sendfile', base_path("storage/app/public/$filename"));
    }

nginx 配置

    root /var/www/public;
#...
    location /storage/ {
      alias /var/www/storage/;
      internal;
    }
#also i tried root key same result not changed

我認為別名沒有覆蓋父 scope 根密鑰,但我沒有解決這個問題。

Nginx Log ---
[error] 35#35: *1 open() "/var/www/public/storage/app/public/4.jpg" failed (2: No such file or directory),

normaly 文件存儲在 /var/www/storage/app/public/4.jpg

我用 nginx conf 修復了它。 nginx 沒有趕上 url 所以我改變了這些配置

 location ^~ /storage/ {
      alias /var/www/storage/;
      internal;
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM