1
+ user root;
2
+ daemon off;
3
+ master_process on;
4
+ worker_processes 1;
5
+ #worker_rlimit 4g;
6
+
7
+ #error_log logs/error.log;
8
+ #error_log logs/error.log notice;
9
+ error_log logs/error.log error;
10
+
11
+ worker_rlimit_nofile 102400;
12
+ worker_rlimit_core 2G;
13
+ working_directory /tmp/;
14
+
15
+ pid logs/nginx.pid;
16
+
17
+ events {
18
+ use epoll;
19
+ worker_connections 4096;
20
+ multi_listen unix:/tmp/http 80;
21
+ multi_listen unix:/tmp/https 443;
22
+ multi_listen unix:/tmp/rtmp 1935;
23
+
24
+ dynamic_refresh_interval 5s;
25
+ dynamic_domain_buckets 1001;
26
+ resolver 114.114.114.114 valid=10s;
27
+ resolver_timeout 30s;
28
+ }
29
+
30
+ #stream_zone buckets=1024 streams=4096;
31
+
32
+ #dynamic_conf conf/nginx_dynamic.conf 10;
33
+ #dynamic_log logs/dynamic.log info;
34
+
35
+ rtmp {
36
+ # log_format log_bandwidth '{"app":"$app","name":"$name","bitrate":$bitrate,"args":"$args","timestamp":$ntp,"ts":"$time_local","type":"$command","remoteAddr":"$remote_addr","announceIp":"39.101.194.173"}';
37
+ # access_log logs/bandwidth.log log_bandwidth trunc=5s;
38
+
39
+ server {
40
+ listen 1935 so_keepalive=2s:2s:3;
41
+ serverid live;
42
+ out_queue 2048;
43
+ rtmp_auto_pull on;
44
+ rtmp_auto_pull_port unix:/tmp/rtmp;
45
+ timeout 5s;
46
+ max_message 6291456;
47
+ idle_streams off;
48
+
49
+ application audio {
50
+ on_play http://127.0.0.1:6080/v1/live/notify stage=start,done update=30s args=serverid=$serverid&scheme=$scheme&clietip=$remote_addr&silent=1&$pargs;
51
+ on_publish http://127.0.0.1:6080/v1/live/notify stage=start,update,done update=10s args=serverid=$serverid&scheme=$scheme&clientip=$remote_addr&silent=1&$pargs;
52
+ on_pull http://127.0.0.1:6080/v1/live/notify stage=start,done update=30s args=serverid=$serverid&scheme=$scheme&clientip=$remote_addr&$pargs;
53
+ on_push http://127.0.0.1:6080/v1/live/notify stage=start,done update=30s args=serverid=$serverid&scheme=$scheme&clientip=$remote_addr&invoke=push&$pargs;
54
+ on_push http://127.0.0.1:6080/v1/live/notify stage=start,done update=30s args=serverid=$serverid&scheme=$scheme&clientip=$remote_addr&invoke=record&$pargs;
55
+ on_push http://127.0.0.1:6080/v1/live/notify stage=start,done update=30s args=serverid=$serverid&scheme=$scheme&clientip=$remote_addr&invoke=transcode&$pargs;
56
+ on_push http://127.0.0.1:6080/v1/live/notify stage=start,done update=30s args=serverid=$serverid&scheme=$scheme&clientip=$remote_addr&invoke=hls&$pargs;
57
+
58
+ hls off;
59
+ hls_path /tmp/hls;
60
+ hls_fragment 4000ms;
61
+ hls_max_fragment 10000ms;
62
+ hls_playlist_length 12000ms;
63
+ hls_type live;
64
+
65
+ hls2 off;
66
+ mpegts_cache_time 0s;
67
+
68
+ hls2_fragment 2000ms;
69
+ hls2_max_fragment 3000ms;
70
+ hls2_playlist_length 6000ms;
71
+
72
+ live on;
73
+ # wait_key on;
74
+ # wait_video on;
75
+ cache_time 1s;
76
+ send_all on;
77
+ low_latency off;
78
+ fix_timestamp 0s;
79
+ # h265 codecid, default 12
80
+ hevc_codecid 12;
81
+ }
82
+
83
+ application * {
84
+ on_play http://127.0.0.1:6080/v1/live/notify stage=start,done update=30s args=serverid=$serverid&scheme=$scheme&clietip=$remote_addr&silent=1&$pargs;
85
+ on_publish http://127.0.0.1:6080/v1/live/notify stage=start,update,done update=10s args=serverid=$serverid&scheme=$scheme&clientip=$remote_addr&silent=1&$pargs;
86
+ on_pull http://127.0.0.1:6080/v1/live/notify stage=start,done update=30s args=serverid=$serverid&scheme=$scheme&clientip=$remote_addr&$pargs;
87
+ on_push http://127.0.0.1:6080/v1/live/notify stage=start,done update=30s args=serverid=$serverid&scheme=$scheme&clientip=$remote_addr&invoke=push&$pargs;
88
+ on_push http://127.0.0.1:6080/v1/live/notify stage=start,done update=30s args=serverid=$serverid&scheme=$scheme&clientip=$remote_addr&invoke=record&$pargs;
89
+ on_push http://127.0.0.1:6080/v1/live/notify stage=start,done update=30s args=serverid=$serverid&scheme=$scheme&clientip=$remote_addr&invoke=transcode&$pargs;
90
+ on_push http://127.0.0.1:6080/v1/live/notify stage=start,done update=30s args=serverid=$serverid&scheme=$scheme&clientip=$remote_addr&invoke=hls&$pargs;
91
+
92
+ live_record off;
93
+ live_record_path /data/record;
94
+
95
+ hls off;
96
+ hls_path /tmp/hls;
97
+ hls_fragment 4000ms;
98
+ hls_max_fragment 10000ms;
99
+ hls_playlist_length 12000ms;
100
+ hls_type live;
101
+
102
+ hls2 off;
103
+ mpegts_cache_time 0s;
104
+
105
+ hls2_fragment 2000ms;
106
+ hls2_max_fragment 3000ms;
107
+ hls2_playlist_length 6000ms;
108
+
109
+ live on;
110
+ wait_key on;
111
+ wait_video on;
112
+ cache_time 1s;
113
+ send_all on;
114
+ low_latency off;
115
+ fix_timestamp 0s;
116
+ # h265 codecid, default 12
117
+ hevc_codecid 12;
118
+ }
119
+ }
120
+ }
121
+
122
+ http {
123
+ include mime.types;
124
+ default_type application/octet-stream;
125
+
126
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
127
+ '$status $body_bytes_sent "$http_referer" '
128
+ '"$http_user_agent" "$http_X-Forwarded-For" "$http_X-Real-IP" "$host"';
129
+
130
+ access_log logs/access.log main;
131
+
132
+ sendfile on;
133
+ #tcp_nopush on;
134
+
135
+ #keepalive_timeout 0;
136
+ keepalive_timeout 65;
137
+
138
+ #reset_server_name www.test1.com www.test2.com;
139
+ #gzip on;
140
+
141
+ server {
142
+ listen 80;
143
+ listen 443 ssl;
144
+ ssl_certificate /cert/fullchain.pem;
145
+ ssl_certificate_key /cert/privkey.pem;
146
+ location /rtmp_stat {
147
+ rtmp_stat all;
148
+ rtmp_stat_stylesheet /stat.xsl;
149
+ }
150
+
151
+ location /xstat {
152
+ rtmp_stat all;
153
+ }
154
+
155
+ location /sys_stat {
156
+ sys_stat;
157
+ }
158
+
159
+ location /proxy/ {
160
+ rewrite ^/proxy/(.*) /sys_stat break;
161
+ proxy_pass http://$1:;
162
+ }
163
+
164
+ location /bs {
165
+ broadcast unix:/tmp/http /proxy;
166
+ broadcast_rewrite_prefix "," [;
167
+ broadcast_suffix ];
168
+ return 200;
169
+ }
170
+
171
+ location ~ .mp4$ {
172
+ root html;
173
+ #mp4;
174
+ }
175
+
176
+ location /control {
177
+ rtmp_control all;
178
+ }
179
+ location /flv {
180
+ flv_live 1935;
181
+ chunked_transfer_encoding off;
182
+ add_header 'Access-Control-Allow-Origin' '*';
183
+ add_header "Access-Control-Allow-Credentials" "true";
184
+ add_header "Access-Control-Allow-Methods" "*";
185
+ add_header "Access-Control-Allow-Headers" "Content-Type,Access-Token";
186
+ add_header "Access-Control-Expose-Headers" "*";
187
+ }
188
+ location /ts {
189
+ ts_live 1935 app=live;
190
+ expires -1;
191
+ add_header 'Access-Control-Allow-Origin' '*';
192
+ add_header "Access-Control-Allow-Credentials" "true";
193
+ add_header "Access-Control-Allow-Methods" "*";
194
+ add_header "Access-Control-Allow-Headers" "Content-Type,Access-Token";
195
+ add_header "Access-Control-Expose-Headers" "*";
196
+ }
197
+ location /hls {
198
+ types {
199
+ application/vnd.apple.mpegurl m3u8;
200
+ video/mp2t ts;
201
+ }
202
+ root /tmp;
203
+ expires -1;
204
+ add_header Cache-Control no-cache;
205
+ add_header 'Access-Control-Allow-Origin' '*';
206
+ add_header "Access-Control-Allow-Credentials" "true";
207
+ add_header "Access-Control-Allow-Methods" "*";
208
+ add_header "Access-Control-Allow-Headers" "Content-Type,Access-Token";
209
+ add_header "Access-Control-Expose-Headers" "*";
210
+ }
211
+
212
+ location / {
213
+ if ($request_method = 'OPTIONS') {
214
+ add_header 'Access-Control-Allow-Origin' '*' always;
215
+ add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE' always;
216
+ add_header 'Access-Control-Allow-Headers' '*' always;
217
+ add_header 'Access-Control-Max-Age' 1728000 always;
218
+ add_header 'Content-Length' 0;
219
+ add_header 'Content-Type' 'text/plain; charset=utf-8';
220
+ return 200;
221
+ }
222
+ chunked_transfer_encoding on;
223
+ root html/;
224
+ }
225
+ }
226
+ }
0 commit comments