惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
S
Securelist
D
Docker
The Register - Security
The Register - Security
GbyAI
GbyAI
Recorded Future
Recorded Future
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
罗磊的独立博客
博客园 - 【当耐特】
F
Full Disclosure
WordPress大学
WordPress大学
腾讯CDC
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
SecWiki News
SecWiki News
L
Lohrmann on Cybersecurity
I
InfoQ
MyScale Blog
MyScale Blog
量子位
Cyberwarzone
Cyberwarzone
博客园 - 三生石上(FineUI控件)
The Hacker News
The Hacker News
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
博客园_首页
H
Help Net Security
K
Kaspersky official blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
Blog — PlanetScale
Blog — PlanetScale
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
The Cloudflare Blog
P
Proofpoint News Feed
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tailwind CSS Blog
爱范儿
爱范儿
P
Privacy International News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog RSS Feed

博客 | dsy4567 的小站

2024 年总结——我在地址栏输入 A-Z,浏览器会补全哪些域名? | 博客 | dsy4567 的小站 用 Vercel + DevSidecar 实现科学上网 | 博客 | dsy4567 的小站 记一次在 Termux 上搭建 code-server 环境 | 博客 | dsy4567 的小站 如何优化网站加载速度 | 博客 | dsy4567 的小站 使用 Cloudflare Workers 获取别人的 IP 地址 | 博客 | dsy4567 的小站 P1932 题解 | 博客 | dsy4567 的小站 (转) CCF NOI 历年处罚公告 | 博客 | dsy4567 的小站 (水文)2022 €€£ €$₽ J 组第二轮游寄 | 博客 | dsy4567 的小站
使用 CloudFlare Workers 免费搭建 Virtual Judge 反代 | 博客 | dsy4567 的小站
2023-05-20 · via 博客 | dsy4567 的小站

使用 CloudFlare Workers 免费搭建 Virtual Judge 反代

最近闲的没事干,受 如何科学地制作一个镜像反代站点 这篇文章的启发,我一个买不起服务器的穷逼准备用 CF Workers 搭一个 Virtual Judge 反代,以缓解 VJ 在大陆经常断网的情况。而且 CF Workers 有更高的 SLA 保证,如果运气好,访问速度还会嘎嘎快。

千万不要反代反 D、色情、赌博等违规网站,小心你家水表坏了。

注册 CF

这个就不用我浪费口水了,传送门 -> https://dash.cloudflare.com/

创建 CF Worker

这一步需要先把域名绑到 CF 里面,因为 *.workers.dev 有墙。

可以到 Freenom 那里搞一个免费域名.

登录 Cloudflare Dashboard,点击右边的 Workers,再点右边的创建服务。

Workers 面板

服务名称随便,点击创建服务。

创建服务

绑定自定义域。

触发器 > 自定义域,在这里输入 Worker 要绑的域名。

自定义域

点击快速编辑。

管理面板

粘贴以下代码,然后保存并部署:

export default {
    async fetch(request, env, ctx) {
        let u = new URL(request.url);
        const originHost = "vjudge.net",
            mirrorHost = u.hostname;
        u.hostname = originHost;

        Object.defineProperty(request, "url", {
            value: u,
            writable: true,
        });
        let resp = await fetch(u, request);

        if (resp.headers.get("content-type").includes("text/")) {
            let body = await resp.text();
            body.replace(new RegExp(originHost, "g"), mirrorHost);
            return new Response(body, resp);
        }
        return resp;
    },
};

接下来,访问你绑定的域名。

登录镜像站

由于 CF Workers 不让改 set-cookie 请求头,你需要花很大力气登录 vjudge.net,然后把 cookies 复制到镜像站里。

打开 https://vjudge.net,登录后打开开发者工具 > 应用 > cookie > https://vjudge.net

再打开 https://你绑定的域名,登录后打开开发者工具 > 应用 > cookie > https://你绑定的域名,将两个 JSESSIONID 复制粘贴过去,然后刷新镜像站,就可以完成登录。

开发者工具


最后,尽情享受吧~

Demo(已失效):https://vjmirror.workers.dsy4567.cf/


如无特别说明,本作品采用CC BY-NC-SA 4.0进行许可。
发表于: 2023/5/20 22:57:26, 更新于: 2023/5/21 11:19:53
标签: 技术 CloudFlare