我正在尝试找出这个问题的解决方案,不幸的是我不是 Nginx 专家。
我正在尝试找到一种动态代理到运行 Nginx RTMP 的 Docker 容器的方法。
我将拥有执行“路由”的主 Nginx 镜像,并且每个 RTMP 实例都将拥有自己的配置,允许每个实例重新启动而不干扰其他实例。
我的问题是:如何?
我假设我可以根据“ key ”动态路由 RTMP 请求,然后将其代理到适当的端口。
类似的东西?
server {
listen 1935;
chunk_size 4096;
notify_method get;
application live {
on_publish http://localhost/auth;
live on;
record all;
record_path /var/www/html/recordings;
record_unique on;
push rtmp://localhost:$dynport;
}
}
我只是不确定如何让身份验证脚本将端口号传递给 nginx。
最佳答案
您可以使用我创建的这个项目:https://github.com/spartanz51/rtmp-interceptor
并根据用户的 rtmp key 将用户重定向到不同的 RTMP 服务器
const RTMPInterceptor = require('rtmp-interceptor')
const params = {
listenPort: '1936'
}
RTMPInterceptor.listen(params, (client, tcUrl, SKey) => {
console.log('tcUrl: '+tcUrl) /* Do something with the data ... */
console.log('StreamKey: '+SKey)
return { /* Return false to block client and close stream */
host: 'localhost',
port: '1935'
}
})
这会将用户重定向到 localhost:1935
关于docker - Nginx 到 Docker 容器的动态代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63716702/