-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
180 lines (146 loc) · 4.24 KB
/
nginx.conf
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# # Modify user if needed, remove for Docker if running as root user inside container
# # user nginx;
# # Optimize for all CPU cores
# worker_processes auto;
# # Error log inside container
# error_log /var/log/nginx/error.log debug; # Set to 'debug' for troubleshooting, can change to 'info' in production
# # PID file inside container
# pid /var/run/nginx.pid;
# events {
# worker_connections 4096; # Increased for more concurrent connections
# }
# # RTMP block
# rtmp {
# server {
# listen 1935;
# chunk_size 4096;
# # Improved session handling
# out_queue 4096;
# out_cork 16;
# session_relay_timeout 30s;
# application live {
# live on;
# record off;
# # Optional: Disable idle streams to save resources
# idle_streams off;
# }
# application hls {
# live on;
# hls on;
# hls_path /tmp/hls;
# hls_fragment 3s; # Shorter fragment size for lower latency
# hls_playlist_length 10s; # Adjusted for smoother playback
# hls_fragment_naming sequential;
# }
# }
# }
# # HTTP block for stats and HLS
# http {
# # Make sure to include the correct mime.types inside Docker
# include /etc/nginx/mime.types;
# default_type application/octet-stream;
# sendfile on;
# keepalive_timeout 65;
# server {
# listen 8080;
# server_name localhost;
# location / {
# root /usr/share/nginx/html;
# index index.html index.htm;
# }
# # Error pages
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# root /usr/share/nginx/html;
# }
# # RTMP stats
# location /stat {
# rtmp_stat all;
# rtmp_stat_stylesheet stat.xsl;
# }
# location /stat.xsl {
# # You will need to place stat.xsl in this location or adjust the path accordingly
# root /usr/local/nginx/html;
# }
# # HLS streaming
# location /hls {
# types {
# application/vnd.apple.mpegurl m3u8;
# video/mp2t ts;
# }
# root /tmp;
# add_header Cache-Control no-cache;
# # Increased buffer for smooth streaming
# sendfile on;
# tcp_nopush on;
# tcp_nodelay on;
# client_body_buffer_size 10M;
# }
# }
# }
# Modify user if needed, remove for Docker if running as root user inside container
# user nginx;
# worker_processes auto;
# Error log inside container
error_log /var/log/nginx/error.log info;
# PID file inside container
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
# RTMP block
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
}
application hls {
live on;
hls on;
hls_path /tmp/hls;
hls_fragment 5s;
}
}
}
# HTTP block for stats and HLS
http {
# Make sure to include the correct mime.types inside Docker
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
# Error pages
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# RTMP stats
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
# You will need to place stat.xsl in this location or adjust the path accordingly
root /usr/local/nginx/html;
}
# HLS streaming
location /hls {
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp;
add_header Cache-Control no-cache;
}
}
}