繁体   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