-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnginx.conf
156 lines (120 loc) · 3.89 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
worker_processes auto;
events {
use epoll;
}
http {
# basic settings
log_format main '$remote_addr $remote_user [$time_local] "$request" ' '$status "$http_referer" "$http_user_agent"';
access_log /dev/stdout main;
error_log stderr debug;
default_type application/octet-stream;
include /usr/local/nginx/conf/mime.types;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 15;
upstream storage_upstream {
server storage:9000;
}
upstream storage_console_upstream {
server storage:9001;
}
server {
server_name console.localhost;
location / {
proxy_pass http://storage_console_upstream;
}
}
server {
server_name localhost;
# vod module
vod_last_modified 'Sun, 19 Nov 2000 08:52:00 GMT';
vod_last_modified_types *;
vod_metadata_cache metadata_cache 512m;
vod_response_cache response_cache 128m;
vod_segment_duration 10000;
vod_align_segments_to_key_frames on;
vod_manifest_segment_durations_mode accurate;
vod_dash_fragment_file_name_prefix "seg";
vod_hls_segment_file_name_prefix "seg";
# gzip manifests
gzip on;
gzip_types application/vnd.apple.mpegurl;
# file handle caching / aio
open_file_cache max=1000 inactive=5m;
open_file_cache_valid 2m;
open_file_cache_min_uses 1;
open_file_cache_errors on;
aio on;
### Local storage endpoints
# direct streaming from local storage
location /local_raw/ {
alias /opt/static/videos/;
autoindex on;
}
# hls streaming from local storage
location /local_hls/ {
rewrite ^/local_hls/(.*).(mp4|mov|mkv)$ /local_hls/$1.$2/index.m3u8 break;
vod hls;
vod_mode local;
alias /opt/static/videos/;
add_header Access-Control-Allow-Headers '*';
add_header Access-Control-Allow-Origin '*';
add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS';
}
# thumbnail from local storage
location /local_thumb/ {
rewrite ^/local_thumb/(.*).(mp4|mov|mkv)$ /local_thumb/$1.$2/thumb-1000.jpg break;
vod thumb;
vod_mode local;
alias /opt/static/videos/;
add_header Access-Control-Allow-Headers '*';
add_header Access-Control-Allow-Origin '*';
add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS';
}
### Remote storage endpoints
# internal proxy to remote storage, used by vod module for avoid double prefix
location ~* /vs/(remote_thumb|remote_hls)/(.*)$ {
internal;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://storage_upstream/videos/$2;
}
# direct streaming from remote storage
location /remote_raw/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://storage_upstream/videos/;
}
# hls streaming from remote storage
location /remote_hls/ {
rewrite ^/remote_hls/(.*).(mp4|mov|mkv)$ /remote_hls/$1.$2/index.m3u8 break;
vod hls;
vod_mode remote;
vod_upstream_location /vs;
add_header Access-Control-Allow-Headers '*';
add_header Access-Control-Allow-Origin '*';
add_header Access-Control-Expose-Headers 'Server,range,Content-Length,Content-Range';
add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS';
expires 100d;
}
# thumbnail from remote storage
location /remote_thumb/ {
rewrite ^/remote_thumb/(.*).(mp4|mov|mkv)$ /remote_thumb/$1.$2/thumb-20000.jpg break;
vod thumb;
vod_mode remote;
vod_upstream_location /vs;
add_header Access-Control-Allow-Headers '*';
add_header Access-Control-Allow-Origin '*';
add_header Access-Control-Expose-Headers 'Server,range,Content-Length,Content-Range';
add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS';
}
# Hdrezka like short urls example
location ~ /vid/(.*).(mp4|mov|mkv):hls {
rewrite ^/vid/(.*).(mp4|mov|mkv):hls$ /remote_hls/$1.$2/index.m3u8;
}
location ~ /vid/(.*).(mp4|mov|mkv):thumb {
rewrite ^/vid/(.*).(mp4|mov|mkv):thumb$ /remote_thumb/$1.$2/thumb-1000.jpg;
}
}
}