如何密码保护使用PHP的流媒体视频 [英] How to password protect streaming videos with php

查看:170
本文介绍了如何密码保护使用PHP的流媒体视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是使用PHP /的.​​htaccess密码保护的QuickTime Streaming视频的​​最佳方式。他们正在使用RTSP流,但如果需要,我可以使用其他格式。

What is the best way to password protect quicktime streaming videos using php/.htaccess. They are being streamed using rtsp, but I can use other formats if necessary.

我知道如何做认证,使用PHP,但我不知道如何设置身份验证,以便将保护流媒体文件的网址,以便用户不能只是复制url和分享。

I know how to do authentication with php, but I'm not sure how to setup authentication so that will protect the streaming files urls so that a user can't just copy the url and share it.

还是我这得太多,我可以只使用一个正常的身份验证方案,并将该文件放置在受保护的目录?

Or am I overthinking this and I can just use a normal authentication scheme and place the files in a protected directory?

推荐答案

Nginx的都和lighttpd的Web服务器具有的X发送,文件头可以从PHP返回。所以,你可以做你的支票在PHP,然后有条件服务器出该文件。

Both nginx and lighttpd web servers have X-Send-File headers you can return from PHP. So you can do your checks in PHP and then conditionally server out the file.

if (check_user_can_access()){
    header('X-sendfile: /path/to/file');
} else {
    header('HTTP/1.1 403 Fail!');
}

lighttpd的还有一个叫做一个整洁的模块 mod_secure_download ,让您以编程方式生成的URL将只适用于一个短的时间。

Lighttpd also has a neat module called mod_secure_download that allows you to programatically generate a URL that will only be valid for a short time period.

Nginx的,并且可能lighttpd的,允许你帽下载速度,这样你就不会发送数据流的速度比它可以食用。

Nginx, and possibly lighttpd, allow you to cap the download speed, so you're not sending out streaming data faster than it can be consumed.

无论哪种方式,你想用你的web服务器提供文件。为他们提供服务,通过PHP是可能的,但速度缓慢。

Either way, you want to use your web server for serving files. Serving them through PHP is possible, but slow.

这篇关于如何密码保护使用PHP的流媒体视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆