docker - Nginx 到 Docker 容器的动态代理

标签 docker nginx reverse-proxy rtmp

我正在尝试找出这个问题的解决方案,不幸的是我不是 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/

相关文章:

laravel - 如何在docker上诊断404未找到错误nginx?

Docker for windows 的 Docker 日志(驱动程序 json 文件)位置

python - Docker for django 开发自动更新

iis - 如何有条件地在 IIS 中禁用 Keep-Alive?

docker - Windows docker 容器中的 jfrog-cli - x509 : certificate signed by unknown authority

linux - 403 禁止 : nginx is blocking default page

docker运行nginx :latest hangs indefinitely

javascript - php动态子页面和nginx地址重写

javascript - 防止通过 MITM 代理对单个页面进行多次 JS 注入(inject)

ssl - 通过 IIS 反向代理上的 https 设置 YouTrack