如果不想搞的话,可以用我的 https://jsd.ucbk.cn
新建一个网站,然后把下面内容覆盖到nginx配置文件
server {
listen 80;
listen 443 ssl http2;
# 请更改为你的证书路径
ssl_certificate fullchain.pem;
ssl_certificate_key privkey.pem;
# 请更改为你的镜像域名
server_name jsd.ucbk.cn;
location / {
proxy_pass https://cdn.jsdelivr.net;
proxy_set_header Host $proxy_host;
proxy_set_header Accept-Encoding '';
proxy_ssl_server_name on;
proxy_ssl_name $proxy_host;
proxy_redirect / /;
# Proxy Cache
proxy_cache jsdelivr;
proxy_cache_lock on;
proxy_cache_lock_timeout 15s;
proxy_cache_use_stale updating;
proxy_cache_background_update on;
proxy_cache_key $host$request_uri;
proxy_cache_valid 200 301 302 30d;
proxy_cache_valid 500 501 502 503 15s;
proxy_cache_valid any 5m;
# Replace Domain
sub_filter_once off;
sub_filter_types application/javascript application/json text/xml text/css;
sub_filter '$proxy_host' '$host';
}
}
# 缓存路径请根据需要更改
proxy_cache_path /var/tmp/nginx/jsdelivr levels=1:2 use_temp_path=off keys_zone=jsdelivr:300m inactive=30d max_size=30g;
之后直接把网站涉及到cdn.jsdelivr.net
都改成你自己的就可以了,如果不想改的话直接在你网站nginx配置中加以下内容就可以了
sub_filter_once off;
sub_filter_types application/javascript application/json text/xml text/css;
sub_filter 'cdn.jsdelivr.net' 'jsd.ucbk.cn';
路过,围观大佬~