1.首先创建一个属于自己的镜像站
参考链接: 利用cloudflare搭建属于自己的免费Github加速站
首先,点击 Cloud Flare 链接 ,创建一个属于自己的账户
登录后,点击 Workers
这个子域,可以自定义
输入好后点set up
然后选择订阅模式,免费直接free!
免费版本每天的访问次数是10w次,应该是远远够用的!
如果你是第一次用cloudflare还会有邮箱验证,去邮箱验证一下就行了。
验证完后刷新,点击创建
然后点击 创建服务 。
创建服务后,点击快速编辑!
点击快速编辑后,复制下面代码,粘贴到上面代码区域
// 反代目标网站.
const upstream = 'www.google.com'
// 反代目标网站的移动版.
const upstream_mobile = 'www.google.com'
// 访问区域黑名单(按需设置).
const blocked_region = ['TK']
// IP地址黑名单(按需设置).
const blocked_ip_address = ['0.0.0.0', '127.0.0.1']
// 路径替换.
const replace_dict = {
'$upstream': '$custom_domain',
'//archiveofourown.org': ''
}
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request));
})
async function fetchAndApply(request) {
const region = request.headers.get('cf-ipcountry').toUpperCase();
const ip_address = request.headers.get('cf-connecting-ip');
const user_agent = request.headers.get('user-agent');
let response = null;