gpt4 book ai didi

docker - Nginx 动态代理到 Docker 容器

转载 作者:行者123 更新时间:2023-12-02 18:03:28 25 4
gpt4 key购买 nike

我正在尝试为这个问题找出解决方案,不幸的是我不是 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;
}
}
我只是不确定如何让 auth 脚本将端口号传递给 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com