我有一个自定义的RTMP服务器,由nginx-rtmp驱动。
这是我的配置:
server {
listen 1935;
chunk_size 4000;
ping 10s;
ping_timeout 5s;
application live {
live on;
wait_key on;
play_restart on;
}
}当广播公司想要启动直播流时,他/她会将内容发布到rtmp://myserver.com/live/someUserDefinedStreamName。
当观看者想要观看实况流时,他/她将从API端点获得流url,这就是问题所在。
someUserDefinedStreamName从字面上讲是“公共的”,这意味着每个人都可以将内容发布到这个url,以伪装成广播者。
对于这个问题有什么建议,防止观众知道原始的流url?
例如,广播公司将内容发布到rtmp://myserver.com/live/someUserDefinedStreamName,而观众可以使用rtmp://myserver.com/live?someHashString观看流,但如何呢?
发布于 2017-04-29 22:37:10
发布于 2017-05-15 13:22:39
您可以通过nginx-rtmp模块中的选项轻松保护您的rtmp资源,使用on_play保护资源不被播放(通过在自定义后台检查权限),使用on_publish限制发布用户。
rtmp{
application appname{
# a url to your custom backend
on_play http://localhost:9090/check_user;
# backend server should return 200 for allowing otherwise return 401 or 403
# you can also return 301 or 302 like redirection for redirecting to
# other stream
on_publish http://localhost:9090/check_publish_perm;
# same conditions as on_play
}
}发布于 2021-12-30 20:55:50
这是一个较老的问题,因此发布者可能不再需要答案,但以下是我们目前所做的,以防止未经授权的发布者进入我们的rtmp流。如果你的出版商有动态的ip地址,这不是最理想的解决方案。
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
meta copy;
hls on;
hls_path /mnt/hls/live;
hls_fragment 5s;
hls_playlist_length 10s;
allow publish IP_ADDRESS_GOES_HERE;
deny publish all;
}
}allow publish和deny publish行将传入来源限制为允许和拒绝所有其他来源。
目前正在寻找stack上更好的解决方案
https://stackoverflow.com/questions/43696622
复制相似问题