nginx 转发 rtmp 直播流

nginx转发rtmp流

场景描述:服务器1使用nginx-rtmp-module搭建了基于nginx的rtmp推流平台,用户推rtmp流只能推到服务器2,然后转发到服务器1。nginx默认只能转发http,转发rtmp需要另外编译转发tcp的模块。要求nginx版本大于1.9。

1、软件准备

nginx-1.20.2

2、编译安装

cd nginx-1.20.2
sudo ./configure --prefix=/usr/local/nginx --with-stream
sudo make
sudo make install
报错:
(1)./configure: error: C compiler cc is not found
(2)./configure: error: the HTTP rewrite module requires the PCRE library.
(3)./configure: error: SSL modules require the OpenSSL library.
统一解决:sudo apt-get install -y build-essential git-core bison openssl libreadline6-dev curl zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 autoconf libc6-dev libpcre3-dev libcurl4-nss-dev libxml2-dev libxslt-dev imagemagick libffi-dev

3、配置nginx

sudo vim /usr/local/nginx/conf/nginx.conf
项目fhadmin.cn
events {...}
# tcp反向代理
stream {
    server {
        listen 1935;
        proxy_connect_timeout 10s;
        proxy_timeout 15s;
        proxy_pass 10.10.10.10:1935;
    }
}
http {...}

4、启动nginx

sudo /usr/local/nginx/sbin/nginx

 

上一篇:阿里开源!云原生应用自动化引擎 OpenKruise | 直击 KubeCon


下一篇:如何带领团队“攻城略地”?优秀的架构师这样做