RTMP的标准实践仍然是电线上有一个纯文本流键。
我想要从编码器到NGINX的RTMPS流,但是RTMP模块还没有RTMPS。
我对所有的中继解决方案并不感兴趣,这些解决方案允许使用RTMP流并通过RTMPS发送到像facebook这样的地方,因为同样的安全漏洞仍然存在,因为在某个时候,您正在通过纯文本传递密钥。
我的问题是在哪里可以找到RTMPS的参考规范?我想知道需要哪些键才能在RTMPS源代码(如OBS和NGINX )之间进行适当的握手,然后我将使用与RTMP模块的连接。是否可以在服务器上使用普通密钥和权限(如“让我们加密”),以便它可以使用RTMPS编码器进行握手?
我见过特技在TLS里包着RTMP。它可以做反向使用特技接收RTMPS并转换回RTMP为RTMP模块?
发布于 2020-05-30 15:54:59
由于NGINX能够终止上游TCP服务器的TLS,因此应该只使用NGINX (只需将stream部分添加到@Esa Jokinen的配置中)就可以了:
stream {
upstream backend {
server 127.0.0.1:1936;
}
server {
listen 1935 ssl;
proxy_pass backend;
ssl_certificate /etc/letsencrypt/live/rtmp.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/rtmp.example.com/privkey.pem;
}
}
rtmp {
server {
listen 127.0.0.1:1936;
chunk_size 4096;
application app-secret-stream-key {
live on;
record off;
allow publish 127.0.0.1; # for streaming through stunnel
allow play 127.0.0.1; # for the pull from /live
}
application live {
live on;
record off;
deny publish all; # no need to publish on /live
allow play all; # playing allowed
pull rtmp://127.0.0.1:1936/app-secret-stream-key;
}
}
}
http {
server {
listen 80;
server_name rtmp.example.com;
location ^~ /.well-known/acme-challenge/ {
root /var/www/letsencrypt;
}
location / {
return 404;
}
}
}发布于 2020-06-06 12:42:55
我决定将此作为另一个答案发布,因为我的第一个答案仍然是一个很好的解释性的答案,我还想为丹尼拉·弗希宁指出使用Nginx的stream{}__提供学分。然而,虽然这两个答案都通过加密包括密钥在内的内容来提高安全性,但它们也使用存取控制模块的allow/deny [play|publish] address|subnet|all删除了rtmp{}的功能。
stream{}即代理TCP有自己的存取控制,但是(与rtmp{}不同)它不能区分发布和播放:有了一个stream{}代理,每个人都可以发布和播放--或者拒绝做任何一个。因此,使用密钥和IP限制的访问控制需要具有单独代理的结构,用于发布和流:使用密钥代理发布的separete端口。下图演示了此设计:

这里,我使用标准端口1935/tcp进行RTMPS-play,并为RTMPS-发布使用额外的1936/tcp。对于内部未加密的RTMP连接,我使用类似的端口19351和19361。红色表示未加密的连接和不受信任的网络,而绿色表示加密的连接和可信的网络。
代理TCP现在有两种(RTMPS)配置,但它们仍然可以使用相同的证书:
stream {
upstream publish {
server 127.0.0.1:19361;
}
server {
listen 1936 ssl; # additional port for publishing
proxy_pass publish;
ssl_certificate /etc/letsencrypt/live/rtmp.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/rtmp.example.com/privkey.pem;
allow 192.0.2.1; # allow publish from this IP
allow 192.0.2.0/24; # -- also supports CIDR notation!
deny all; # deny publish from the rest
}
upstream live {
server 127.0.0.1:19351;
}
server {
listen 1935 ssl; # standard RTMP(S) port
proxy_pass live;
ssl_certificate /etc/letsencrypt/live/rtmp.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/rtmp.example.com/privkey.pem;
allow all; # this is public (this is also the default)
}
}同样,对于每个应用程序,我们现在需要两个单独的(本地回送) RTMP服务器:
rtmp {
server {
listen 127.0.0.1:19361;
chunk_size 4096;
application secret-key {
live on;
record off;
allow publish 127.0.0.1; # publishing through rtmps://rtmp.example.com:1936
allow play 127.0.0.1; # for the pull from rtmp://localhost:19351/live
}
}
server {
listen 127.0.0.1:19351;
chunk_size 4096;
application live {
live on;
record off;
deny publish all; # no need to publish on /live -- IMPORTANT!!!
allow play 127.0.0.1; # playing through rtmps://rtmp.example.com:1935/live
pull rtmp://127.0.0.1:19361/secret-key;
}
}
}实际的基于IP的访问控制是在stream{}部分完成的,因此只有deny publish all;才是防止使用/live应用程序直接发布的必要条件。我将allow指令添加到rtmp{}部分,只是为了澄清(和注释) RTMP访问控制的默认行为。
发布于 2020-11-20 23:23:15
这里不确定这是否有效,但我像上面一样使用简单的SSL终止和代理协议来保持客户端IP地址。RTMP模块支持代理协议,因此仍然可以允许IP地址拒绝。做了一些基本的测试,它似乎工作得很好,正确的消息在日志和拒绝IP地址工作。
也许我错过了理解,但它似乎在做我认为应该做的事情,即允许通过RTMPS进行SSL连接,并在RTMP模块中保留用于访问控制的客户端IP地址。
我的流块看起来如下:
stream {
upstream backend {
server 127.0.0.1:1935;
}
server {
listen 1936 ssl;
proxy_pass backend;
proxy_protocol on;
ssl_certificate /etc/..../fullchain.pem;
ssl_certificate_key /etc/.../privkey.pem;
}
}以及我的RTMP部分的相关部分:(注意:直接连接可能不起作用,但没有在博客中尝试it...suggests (见下文),但我不需要直接连接)。
rtmp {
server {
listen 1935 proxy_protocol;
chunk_size 4000;
application stream_app{
live on;
.....
.....
.....
}
}
}
}你可以在RTMP博客http://nginx-rtmp.blogspot.com上读到它。
希望它能帮助别人,感谢他们的回答,因为他们给了我正确的方向。
如果我否认所有的发挥,因为我正在推出他的as,不需要发挥或其他任何事情在目前。
https://serverfault.com/questions/1019317
复制相似问题