节点搭建Cloudflare workers反代代码
科技小岛Cloudflare的反代域名/ip的workers代码
选择以下任意一个代码,粘贴至cloudflare的workers代码中;
修改有注释的地方,然后可以选择绑定一个自定义域名,即可形成反代域名。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| export default { async fetch(request, env) { let url = new URL(request.url); if (url.pathname.startsWith('/')) { var arrStr = [ 'aaaa.bbbbb.hf.space', ]; url.protocol = 'https:' url.hostname = getRandomArray(arrStr) let new_request = new Request(url, request); return fetch(new_request); } return env.ASSETS.fetch(request); }, }; function getRandomArray(array) { const randomIndex = Math.floor(Math.random() * array.length); return array[randomIndex]; }
|
1 2 3 4 5 6 7 8 9 10 11
| export default { async fetch(request, env, ctx) { let url = new URL(request.url); if(url.pathname.startsWith('/')){ url.hostname="translate.google.com"; let new_request = new Request(url, request) return await fetch(new_request) } return await env.ASSETS.fetch(request); }, };
|