-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
nginx.conf
268 lines (204 loc) · 8.31 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# Replace all fields where you find "{HERE}" Without quotes
# Replace this with what you indicate in your respective comment located on the right.
#user nobody;
worker_processes 1;
error_log logs/rtmp_error.log debug;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
# set client body size to 256M #
# client_max_body_size 256M;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/css text/javascript text/xml text/plain image/x-icon image/svg+xml application/rss+xml application/javascript application/x-javascript application/xml application/xhtml+xml application/x-font application/x-font-truetype application/x-font-ttf application/x-font-otf application/x-font-opentype application/vnd.ms-fontobject font/ttf font/otf font/opentype;
server {
listen 8080;
server_name {HERE}; # Replace with your domain name, for example: example.com or localhost
#charset koi8-r;
#access_log logs/host.access.log main;
location /streaming {
# Serve HLS fragments
# CORS setup
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length';
# allow CORS preflight requests
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root {HERE}; # Replace with the location where the "uploads/temp" folder is located, for example: /usr/local/var/www/tubeak/uploads/temp
add_header Cache-Control no-cache;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME {HERE}$fastcgi_script_name; # Replace with the location (Root) where the script is located, for example: /usr/local/var/www/tubeak/
include fastcgi_params;
}
root {HERE}; # Replace with the location (Root) where the script is located, for example: /usr/local/var/www/tubeak/
index index.php;
location ~ (css|js|img|m3u8|ts|mp4) {
try_files $uri $uri/ =404;
}
location / {
if (!-e $request_filename){
rewrite ^/$ index.php?one=home;
}
if (!-e $request_filename){
rewrite ^/([^\/]+)(\/|)$ index.php?one=$1;
}
}
location /reset-password {
rewrite ^/reset-password/([^\/]+)(\/|)$ index.php?one=reset-password&code=$1;
}
location /verify-email {
rewrite ^/verify-email/([^/.]+)/([^\/]+)(\/|)?$ index.php?one=verify-email&code=$1&id=$2;
}
location /authentication {
rewrite ^/authentication/([^/.]+)/([^\/]+)(\/|)?$ index.php?one=authentication&code=$1&id=$2;
}
location /change-email {
rewrite ^/change-email/([^/.]+)/([^\/]+)(\/|)?$ index.php?one=change-email&code=$1&id=$2;
}
location /not-me {
rewrite ^/not-me/([^/.]+)/([^\/]+)(\/|)?$ index.php?one=not-me&code=$1&id=$2;
}
location /admin {
rewrite ^/admin$ index.php?one=admin&two=manage-dashboard;
rewrite ^/admin/([^/.]+)?$ index.php?one=admin&two=$1;
rewrite ^/admin/([^/.]+)/([^/.]+)?$ index.php?one=admin&two=$1&three=$2;
}
location /user {
rewrite ^/user/([^/.]+)?$ index.php?one=user&two=$1;
}
location /categories {
rewrite ^/categories/([^/.]+)$ index.php?one=categories&two=$1;
}
location /edit-video {
rewrite ^/edit-video/(.*)?$ index.php?one=edit-video&two=$1;
}
location /download-video {
rewrite ^/download-video/([^/.]+)?$ index.php?one=download-video&video_id=$1;
}
location /embed {
rewrite ^/embed/([^\/]+)(\/|)?$ index.php?one=embed&two=$1;
}
location /pages {
rewrite ^/pages/([^\/]+)(\/|)$ index.php?one=pages&two=$1;
}
location /req {
if (!-e $request_filename){
rewrite ^/req/([^/.]+)/?$ requests.php?request-name=$1;
}
rewrite ^/req/([^/.]+)/([^/.]+)/?$ requests.php?request-name=$1&one=$2;
}
location /stat.xsl {
satisfy any;
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
allow {HERE}; # Replace with the ip of your server, for example: 111.111.1.11
deny all; # Deny everyone else
}
location /control {
rtmp_control all;
# Enable CORS
add_header Access-Control-Allow-Origin * always;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
include servers/*;
}
rtmp {
server {
listen 1935;
chunk_size 8192;
ping 30s;
application live {
live on;
hls on;
hls_fragment 5s;
# Pointing this to an SSD is better as this involves lots of IO
hls_path {HERE}; # Replace with the location where the "uploads/temp" folder is located, for example: /usr/local/var/www/tubeak/uploads/temp
on_publish {HERE}/rtmp-auth.php; # Replace with the host where your "rtmp-auth.php" file is located, for example: http://111.111.1.11:8080
on_publish_done {HERE}/rtmp-done.php; # Replace with the host where your "rtmp-done.php" file is located, for example: http://111.111.1.11:8080
notify_update_timeout 10s;
on_update {HERE}/rtmp-update.php; # Replace with the host where your "rtmp-update.php" file is located, for example: http://111.111.1.11:8080
record all;
record_path {HERE}; # Replace with the location where the "uploads/streaming" folder is located, for example: /usr/local/var/www/tubeak/uploads/streaming/
exec_publish_done bash -c ' tee -a {HERE}/$name/index.m3u8 <<< "#EXT-X-ENDLIST"'; # Replace with the location where the "uploads/temp" folder is located, for example: /usr/local/var/www/tubeak/uploads/temp
}
}
}