-
Notifications
You must be signed in to change notification settings - Fork 9
/
openresty-cahe-wowza-gzip-hash-lua.conf
80 lines (62 loc) · 2.61 KB
/
openresty-cahe-wowza-gzip-hash-lua.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
user nginx;
worker_processes auto;
events {
worker_connections 4096;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
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;
#error_log logs/error.log;
proxy_cache_use_stale updating;
proxy_cache_path /mnt/store/nginx_cache levels=1:2 keys_zone=dvr_cache:10m max_size=2g inactive=30m use_temp_path=off;
add_header X-Cache-Status $upstream_cache_status;
proxy_cache dvr_cache;
proxy_cache_key $uri;
proxy_set_header Accept-Encoding "";
gzip on;
gzip_types application/vnd.apple.mpegurl;
server {
listen 8080;
server_name _;
set $wowza_ip '127.0.0.1';
location ~ \.(ts)$ {
proxy_pass http://$wowza_ip:1935;
}
location ~ chunklist.*\.(m3u8)$ {
proxy_pass http://$wowza_ip:1935$uri;
header_filter_by_lua_block {
ngx.header.content_length = nil
}
body_filter_by_lua_block {
if ngx.var.arg_h then
ngx.arg[1] = ngx.re.sub(ngx.arg[1],'{encKeySessionid}', "h=" .. ngx.var.arg_h)
ngx.header.content_length = string.len(ngx.arg[1]) .. "\\n"
end
}
}
location ~ playlist.*\.(m3u8)$ {
proxy_pass http://$wowza_ip:1935$uri?DVR;
header_filter_by_lua_block {
ngx.header.content_length = nil
}
body_filter_by_lua_block {
if ngx.var.arg_h then
ngx.arg[1] = ngx.re.gsub(ngx.arg[1],".m3u8", ".m3u8?h=" .. ngx.var.arg_h)
ngx.header.content_length = string.len(ngx.arg[1]) .. "\\n"
end
}
}
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
}