Note: 如果觉得Github的Wiki访问太慢,可以访问 Gitee 镜像。
DRM重要的功能就是防盗链,只有允许的用户,才能访问服务器的流。有多种DRM的方式:
SRS支持refer防盗链,adobe的flash在播放RTMP流时,会把页面的http url放在请求中, as客户端代码不可以更改。当然如果用自己的客户端,不用flash播放流,就可以随意伪造了; 尽管如此,refer防盗链还是能防住相当一部分盗链。
配置Refer防盗链,在vhost中开启refer即可,可以指定publish和play的refer:
# the vhost for antisuck.
vhost refer.anti_suck.com {
# refer hotlink-denial.
refer {
# whether enable the refer hotlink-denial.
# default: off.
enabled on;
# the common refer for play and publish.
# if the page url of client not in the refer, access denied.
# if not specified this field, allow all.
# default: not specified.
all github.com github.io;
# refer for publish clients specified.
# the common refer is not overrided by this.
# if not specified this field, allow all.
# default: not specified.
publish github.com github.io;
# refer for play clients specified.
# the common refer is not overrided by this.
# if not specified this field, allow all.
# default: not specified.
play github.com github.io;
}
}
备注:SRS1/2的Refer配置方法和SRS3不一致,SRS3兼容SRS1/2的配置方法。
token类似于refer,不过是放在RTMP url中,或者在connect的请求参数中:
rtmp://vhost/app?token=xxxx/stream
,这样服务器在on_connect回调接口中,
就会把url带过去验证。参考:HTTP callback
token比refer更强悍,可以指定超时时间,可以变更token之类。可惜就是需要服务器端做定制,做验证。 SRS提供http回调来做验证,已经有人用这种方式做了,比较简单靠谱。
举个常用的token认证的例子:
on_connect http://127.0.0.1:8085/api/v1/clients;
,
参考:HTTP callback
Token防盗链的穿越,指的是在origin-edge集群中,客户播放edge边缘服务器的流时, 边缘将认证的token发送给源站进行验证,即token穿越。
FMS的edge和FMS的origin使用私有协议,使用一个连接回源取数据,一个连接回源传输控制命令, 譬如token穿越就是在这个连接做的。参考:https://github.com/ossrs/srs/issues/104
token认证建议使用http方式,也就是说客户端连接到边缘时,边缘使用http回调方式验证token。 像fms那种token穿越,是需要走RTMP协议,其他开源服务器一般都不支持这种方式(中国特色)。
SRS可以支持类似fms的token穿越,不过实现方式稍微有区别,不是采用fms edge的私有协议, 而是每次新开一个连接回源验证,验证通过后边缘才提供服务。也就是边缘先做一个完全的代理。
SRS这种方式的特点是:
对于源站短连接过多的问题,可以加一层fms边缘缓解,假设1000个客户端连接到边缘:
SRS的token穿越(traverse)的配置,参考edge.token.traverse.conf
:
listen 1935;
vhost __defaultVhost__ {
cluster {
mode remote;
origin 127.0.0.1:19350;
token_traverse on;
}
}
SRS暂时不支持。
SRS暂时不支持,是RTMP特殊的握手协议。
Winlin 2015.8
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。