繁体   English   中英

php nginx X-Accel-Redirect标头

[英]php nginx X-Accel-Redirect headers

我有一个关于使用nginx保护带有静态文件的文件夹的问题,所以基本上我在nginx设置上有根文件夹:

/home/rise/rises/wwwdir

安全文件夹是:

/home/rise/rises/videop

如我们所见,我将该文件夹移到了根文件夹之外,以防止/仅允许根据条件查看

当我第一次发布前进行搜索时,我读到了一些访问根外部videop文件夹的想法,我需要在nginx conf中创建这样的别名,并进行内部访问

location /videop {
        root /home/rise/rises/;
         internal;
        }

但是我在PHP方面要加载视频...

$aliasedFile = '/videop/5_.m3u8';
$filename = '5_.m3u8';
header("Content-Description: File Transfer");
header("Content-Type application/x-mpegURL ");
header('Content-Disposition: attachment; filename='.$filename.'');
header('X-Accel-Redirect: '. $aliasedFile);
readfile($aliasedFile);

我想念什么吗?

您的root指令的URL末尾带有/ ,后跟/ ,因此请使用:

location /videop {
  root /home/rise/rises;
  internal;
}

您的PHP的标头格式不正确,在Content-Type之后应包含:

PHP不应该包含主体。 readfile错误。 PHP的全部目的是发出一个内部重定向,该重定向由nginx拾取。 因此,PHP应该仅返回header

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM