-
Notifications
You must be signed in to change notification settings - Fork 13
/
emby.vcl
44 lines (39 loc) · 1019 Bytes
/
emby.vcl
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
vcl 4.1;
backend default {
.host = "127.0.0.1";
.port = "8096";
}
sub vcl_recv {
# 流媒体播放
if (req.http.Range ~ "bytes=") {
set req.http.x-range = req.http.Range;
}
if (req.url ~ "stream") {
return(synth(750, "Stream"));
}
# API业务 且 不是图片 或 为用户业务请求 则 不缓存
if (req.url ~ "/emby/" && !req.url ~ "Primary" || req.url ~ "/Users/") {
return(pass);
}
# 全量缓存
return(hash);
}
sub vcl_synth {
# 重定向到 流媒体反代
if (resp.status == 750) {
set resp.http.Location = "http://127.0.0.1:10000/" + req.url;
set resp.status = 302;
return(deliver);
}
}
sub vcl_backend_fetch {
if (bereq.http.x-range) {
set bereq.http.Range = bereq.http.x-range;
}
}
sub vcl_backend_response {
if (bereq.http.x-range ~ "bytes=" && beresp.status == 206) {
set beresp.ttl = 10m;
set beresp.http.CR = beresp.http.content-range;
}
}