-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcdn.conf
36 lines (29 loc) · 1.11 KB
/
cdn.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
## /etc/nginx/conf.d/cdn.conf;
server {
listen 8080 default_server;
server_name _;
resolver local=on;
set_by_lua $backend_url 'return os.getenv("BACKEND_URL") or "hello"';
location / {
slice 1m; #缓存分片大小
proxy_cache my_cache; # 使用的缓存
proxy_cache_key $uri$is_args$slice_range; #缓存的key,命中规则依赖这个
proxy_set_header Range $slice_range;
proxy_cache_valid 200 206 1h;
proxy_cache_valid 301 302 10m;
proxy_cache_valid any 1m;
#proxy_cache_valid 404 1m;
add_header X-Cache-Status $upstream_cache_status;
# 支持 Range 请求
proxy_set_header Range $http_range;
#proxy_set_header If-Range $http_if_range;
proxy_pass $backend_url;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $scheme;
# 缓存分片响应,避免缓存整个大文件
#proxy_force_ranges on;
}
client_max_body_size 10240m;
}