nginx创建rtmp反向代理
安装 nginx 和 需要的 nginx module
1
2sudo apt install nginx libnginx-mod-rtmp -y
sudo systemctl enable --now nginxnginx 加入 rtmp 配置块
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19# 确认以下配置是否存在,没有不会调用 rtmp 模块
include /etc/nginx/modules-enabled/*.conf;
# 添加以下配置块配置rtmp方向代理
# 如果代理 rtmps 需要 tcp 通道配合,rtmp协议可以直接反向代理
rtmp {
server {
listen 1935;
chunk_size 4096;
application app {
live on;
push rtmp://127.0.0.1:1936/app;
}
application live {
live on;
push rtmp://127.0.0.1:1937/live;
}
}
}测试 nginx 配置正确以后重载 nginx
1
2nginx -t
nginx -s reload解决 rtmps 代理的 tcp 通道 gost 配置
1
2
3
4
5
6mkdir gost
cd gost
wget https://github.com/go-gost/gost/releases/download/v3.0.0-rc10/gost_3.0.0-rc10_linux_amd64.tar.gz
tar zvxf gost_3.0.0-rc10_linux_amd64.tar.gz
./gost -C ./config.yamlgost 配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40services:
- name: tw-in
addr: ":1936"
handler:
type: tcp
chain: tw-out
listener:
type: tcp
- name: bn-in
addr: ":1937"
handler:
type: tcp
chain: bn-out
listener:
type: tcp
chains:
- name: tw-out
hops:
- name: hop-0
nodes:
- name: node-0
addr: tyo03.contribute.live-video.net:443
connector:
type: forward
dialer:
type: tls
- name: bn-out
hops:
- name: hop-0
nodes:
- name: node-0
addr: bnlivepush-ag.bblivestream.com:443
connector:
type: forward
dialer:
type: tls