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