Skip to content

Commit ba726b4

Browse files
committed
feat(all): 修改workflows、HTTP-FLV端口将9000修改为80、修改部分配置
1. 修改workflows 2. nginx升级到1.26.2 3. HTTP-FLV端口将9000修改为80 4. 增加hls、dash、tml、stat、control模块 5. 更新最新版alpine镜像,解决漏洞问题 6. 修改部分配置
1 parent de1c4a0 commit ba726b4

File tree

11 files changed

+648
-43
lines changed

11 files changed

+648
-43
lines changed

.DS_Store

4 KB
Binary file not shown.

.github/workflows/docker-image.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
env:
1010
# 设置 docker 镜像名
11-
IMAGE_NAME: nginx-http-flv
11+
IMAGE_NAME: nginx-http-flv-module
1212

1313
jobs:
1414
# 运行测试,如果需要的话,将注释取消掉并且修改为自己需要的内容
@@ -39,8 +39,13 @@ jobs:
3939
- uses: actions/checkout@v2
4040
# 构建镜像,指定镜像名
4141
- name: Build image
42-
run: docker build . --file Dockerfile --tag $IMAGE_NAME
43-
# 登录到 dockerhub,使用 GitHub secrets 传入账号密码,密码被加密存储在 GitHub 服务器,添加方法见下图。
42+
run: |
43+
# 如果版本不带ffmpeg,打包之前将Dockerfile中的ffmpeg替换为空
44+
if [[ "${{ github.ref }}" != "refs/tags/"* ]]; then
45+
sed -i 's/ffmpeg//g' Dockerfile
46+
fi
47+
docker build . --file Dockerfile --tag $IMAGE_NAME
48+
# 登录到 dockerhub,使用 GitHub secrets 传入账号密码,密码被加密存储在 GitHub 服务器,添加方法见下图。
4449
- name: Log into registry
4550
run: echo "${{ secrets.ACCESS_TOKEN }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
4651

@@ -63,7 +68,10 @@ jobs:
6368
6469
echo IMAGE_ID=$IMAGE_ID
6570
echo VERSION=$VERSION
71+
6672
# 设置镜像 id 和版本号
6773
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
74+
# 创建一个多平台构建环境
75+
docker buildx create --name multi-platform --use --platform linux/amd64,linux/arm64 --driver docker-container
6876
# 进行 push
69-
docker push $IMAGE_ID:$VERSION
77+
docker buildx build --platform linux/arm64,linux/arm64/v8,linux/ppc64le,linux/amd64,linux/386 -t $IMAGE_ID:$VERSION . --push

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
.idea
3+
.vscode

.idea/.gitignore

Lines changed: 0 additions & 8 deletions
This file was deleted.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.idea/vcs.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG NGINX_VERSION=1.24.0
1+
ARG NGINX_VERSION=1.26.2
22
ARG NGINX_HTTP_FLV_MODULE=1.2.11
33
ARG HTTP_PORT=80
44
ARG HTTPS_PORT=443
@@ -62,8 +62,9 @@ COPY --from=build-nginx /etc/nginx /etc/nginx
6262

6363
# Add NGINX path, config and static files.
6464
ENV PATH "${PATH}:/usr/local/nginx/sbin"
65+
RUN mkdir -p /opt/data && mkdir /www && mkdir -p /usr/local/nginx/rtmp
6566
COPY nginx.conf /etc/nginx/nginx.conf
66-
RUN mkdir -p /opt/data && mkdir /www
67+
COPY stat.xsl /usr/local/nginx/rtmp/stat.xsl
6768
# COPY static /www/static
6869

6970
EXPOSE 80

README-zh.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
* @Description:
33
* @Author: LLiuHuan
44
* @Date: 2022-04-11 16:30:02
5-
* @LastEditTime: 2024-04-06 15:45:59
5+
* @LastEditTime: 2024-07-11 15:15:36
66
* @LastEditors: LLiuHuan
77
-->
88
### 介绍
99
> nginx-http-flv-module官方镜像是四年前的,因项目需要弄个最新版
1010
11-
1. 本项目使用最新版 `nginx-http-flv-module` 目前版本为 `1.2.10`
11+
1. 本项目使用最新版 `nginx-http-flv-module` 目前版本为 `1.2.11`
1212
2. rtmp和http nginx 解析都为 stream,有需要可自行修改
1313

1414
### 使用
@@ -48,5 +48,4 @@ ACCESS_TOKEN 是你的 Docker 密码
4848
- https://hub.docker.com/r/mycujoo/nginx-http-flv-module
4949
- https://blog.csdn.net/a_917/article/details/106709928
5050
- https://blog.csdn.net/Prinz_Corn/article/details/120746676
51-
- https://blog.csdn.net/xjcallen/article/details/107174374
52-
-
51+
- https://blog.csdn.net/xjcallen/article/details/107174374

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Description:
33
* @Author: LLiuHuan
44
* @Date: 2022-04-11 16:30:02
5-
* @LastEditTime: 2024-04-06 15:45:57
5+
* @LastEditTime: 2024-07-16 16:07:04
66
* @LastEditors: LLiuHuan
77
-->
88
### Introduce
@@ -49,5 +49,4 @@ Automatically execute workflow, build Docker image, and upload Docker Hub when p
4949
- https://hub.docker.com/r/mycujoo/nginx-http-flv-module
5050
- https://blog.csdn.net/a_917/article/details/106709928
5151
- https://blog.csdn.net/Prinz_Corn/article/details/120746676
52-
- https://blog.csdn.net/xjcallen/article/details/107174374
53-
-
52+
- https://blog.csdn.net/xjcallen/article/details/107174374

nginx.conf

Lines changed: 79 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,61 @@
11
user root;
2-
worker_processes auto;
2+
worker_processes 1; #运行在 Windows 上时,设置为 1,因为 Windows 不支持 Unix domain socket
3+
#worker_processes auto; #1.3.8 和 1.2.5 以及之后的版本
4+
5+
#worker_cpu_affinity 0001 0010 0100 1000; #只能用于 FreeBSD 和 Linux
6+
#worker_cpu_affinity auto; #1.9.10 以及之后的版本
7+
8+
error_log logs/error.log error;
9+
10+
#如果此模块被编译为动态模块并且要使用与 RTMP 相关的功
11+
#能时,必须指定下面的配置项并且它必须位于 events 配置
12+
#项之前,否则 NGINX 启动时不会加载此模块或者加载失败
13+
14+
#load_module modules/ngx_http_flv_live_module.so;
315

416
# error_log /var/log/nginx/error.log notice;
517
# pid /var/run/nginx.pid;
618

719
events {
8-
worker_connections 1024; ## Default: 1024
20+
worker_connections 4096; ## Default: 1024
921
}
1022

23+
rtmp_auto_push on;
24+
rtmp_auto_push_reconnect 1s;
25+
rtmp_socket_dir /tmp;
26+
1127
rtmp {
28+
out_queue 4096;
29+
out_cork 8;
30+
max_streams 128;
31+
timeout 15s;
32+
drop_idle_publisher 15s;
33+
34+
log_interval 5s; #log 模块在 access.log 中记录日志的间隔时间,对调试非常有用
35+
log_size 1m; #log 模块用来记录日志的缓冲区大小
36+
1237
server {
1338
listen 1935; # 接受推流的端口号
1439
chunk_size 8192; # 单一推流数据包的最大容量?
1540
access_log off; # 加上这行,取消操作日志
1641
application stream { # mlive 模块,可以自行更换名字
1742
live on; # 打开直播
1843
meta off; # 为了兼容网页前端的 flv.js,设置为 off 可以避免报错
19-
gop_cache off; # 支持GOP缓存,以减少首屏时间 改为off 要不不试试同步
44+
gop_cache on; # 支持GOP缓存,以减少首屏时间 改为off 延迟较大
2045
allow play all; # 允许来自任何 ip 的人拉流
2146
}
47+
48+
application hls { # hls 模块,可以自行更换名字
49+
live on;
50+
hls on;
51+
hls_path /tmp/hls;
52+
}
53+
54+
application dash { # dash 模块,可以自行更换名字
55+
live on;
56+
dash on;
57+
dash_path /tmp/dash;
58+
}
2259
}
2360
}
2461

@@ -37,23 +74,55 @@ http {
3774
#gzip on;
3875
server {
3976
listen 80; # http 服务的端口
40-
server_name localhost;
77+
# server_name localhost;
4178
location / {
4279
root html;
4380
index index.html index.htm;
44-
flv_live on; # 打开 http-flv 服务
45-
chunked_transfer_encoding on;
4681
add_header 'Access-Control-Allow-Origin' '*'; # 允许跨域
4782
add_header 'Access-Control-Allow-Credentials' 'true';
4883
}
49-
}
50-
server {
51-
listen 9000;
84+
5285
location /stream {
5386
flv_live on; # 打开 http-flv 服务
54-
chunked_transfer_encoding on;
87+
chunked_transfer_encoding on; #支持 'Transfer-Encoding: chunked' 方式回复
88+
5589
add_header 'Access-Control-Allow-Origin' '*'; # 允许跨域
5690
add_header 'Access-Control-Allow-Credentials' 'true';
5791
}
92+
93+
location /hls { # hls 服务 根据需求修改
94+
types {
95+
application/vnd.apple.mpegurl m3u8;
96+
video/mp2t ts;
97+
}
98+
99+
root /tmp;
100+
add_header 'Cache-Control' 'no-cache';
101+
}
102+
103+
location /dash { # dash 服务 根据需求修改
104+
root /tmp;
105+
add_header 'Cache-Control' 'no-cache';
106+
}
107+
108+
location /stat { # 推流播放和录制统计数据的配置 根据需求确定是否开放
109+
rtmp_stat all;
110+
rtmp_stat_stylesheet stat.xsl;
111+
}
112+
113+
location /stat.xsl {
114+
root rtmp; #指定 stat.xsl 的位置
115+
}
116+
117+
#如果需要 JSON 风格的 stat, 不用指定 stat.xsl
118+
#但是需要指定一个新的配置项 rtmp_stat_format
119+
#location /stat {
120+
# rtmp_stat all;
121+
# rtmp_stat_format json;
122+
#}
123+
124+
location /control {
125+
rtmp_control all; #rtmp 控制模块的配置
126+
}
58127
}
59128
}

0 commit comments

Comments
 (0)