nginx 轉發 rtmp 直播流

FH-Admin發表於2021-12-27

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
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章