-
Notifications
You must be signed in to change notification settings - Fork 4
/
data.jsdmirror.com.nginx.conf
57 lines (44 loc) · 1.92 KB
/
data.jsdmirror.com.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
#PROXY-START/
location ^~ / {
# 启用代理缓冲区选项
proxy_buffering on;
# 设置代理缓冲区大小
proxy_buffer_size 128k;
proxy_buffers 64 128k;
proxy_busy_buffers_size 2048k;
proxy_max_temp_file_size 1024m;
# 启用 TCP nodelay 选项
tcp_nodelay on;
# 代理到目标服务器
proxy_pass https://data.jsdelivr.com;
# 设置代理请求头
proxy_set_header Host data.jsdelivr.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1;
proxy_ssl_name data.jsdelivr.com;
proxy_ssl_server_name on;
# 替换 <title> 标签中的文本
sub_filter '<title>jsDelivr' '<title>JSDMirror';
sub_filter '<title>JsDelivr' '<title>JSDMirror'; # 处理大写情况
sub_filter '<title>JSDELIVR' '<title>JSDMirror'; # 处理全大写情况
# 替换 <text> 标签中的文本(确保 x, y, transform 等属性不会变化)
sub_filter '<text .*?>jsDelivr</text>' '<text $1>JSDMirror</text>'; # 注意这里使用 $1 是不准确的,因为 sub_filter 不支持捕获组
sub_filter '<text x="265" y="140" transform="scale(.1)" fill="#fff" textLength="410">jsDelivr</text>' '<text x="265" y="140" transform="scale(.1)" fill="#fff" textLength="410">JSDMirror</text>';
# 关闭 sub_filter_once,以便所有匹配的文本都会被替换
sub_filter_once off;
# 指定 sub_filter 应用的 MIME 类型
sub_filter_types application/xml image/svg+xml;
# 添加自定义响应头
add_header X-Cache $upstream_cache_status;
# 忽略某些响应头
proxy_ignore_headers Set-Cookie Cache-Control expires;
# 设置缓存
proxy_cache cache_one;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 304 301 302 120m;
}
#PROXY-END/