[英]php nginx X-Accel-Redirect headers
i have an issue regarding protecting folder with static files using nginx so basically i have root folder on nginx setup to : 我有一个关于使用nginx保护带有静态文件的文件夹的问题,所以基本上我在nginx设置上有根文件夹:
/home/rise/rises/wwwdir
and the secured folder is : 安全文件夹是:
/home/rise/rises/videop
as we can see i moved that folder outside root folder to prevent/allow only specific to see under criteria 如我们所见,我将该文件夹移到了根文件夹之外,以防止/仅允许根据条件查看
when i first made a search before posting i read some ideas that to access the videop folder outside the root , i need to create alias in nginx conf like this which i made and access internal 当我第一次发布前进行搜索时,我读到了一些访问根外部videop文件夹的想法,我需要在nginx conf中创建这样的别名,并进行内部访问
location /videop {
root /home/rise/rises/;
internal;
}
however i have an issue on php side to load the video... 但是我在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);
i'm missing something ? 我想念什么吗?
Your root
directive has a trailing /
which will be followed by the leading /
of the URL, so use: 您的
root
指令的URL末尾带有/
,后跟/
,因此请使用:
location /videop {
root /home/rise/rises;
internal;
}
Your PHP has a badly formed header, which should include a :
after Content-Type
. 您的PHP的标头格式不正确,在
Content-Type
之后应包含:
The PHP should should not include a body. PHP不应该包含主体。 The
readfile
is wrong. readfile
错误。 The whole purpose of the PHP is to issue an internal redirect which is picked up by nginx
. PHP的全部目的是发出一个内部重定向,该重定向由
nginx
拾取。 So the PHP should return header
s only. 因此,PHP应该仅返回
header
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.