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

推荐订阅源

P
Proofpoint News Feed
WordPress大学
WordPress大学
Help Net Security
Help Net Security
Jina AI
Jina AI
Security Latest
Security Latest
Y
Y Combinator Blog
Project Zero
Project Zero
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
Know Your Adversary
Know Your Adversary
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
NISL@THU
NISL@THU
Cisco Talos Blog
Cisco Talos Blog
博客园 - 司徒正美
MyScale Blog
MyScale Blog
Cyberwarzone
Cyberwarzone
D
Docker
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
C
CERT Recently Published Vulnerability Notes
B
Blog
L
LangChain Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
SecWiki News
SecWiki News
The Hacker News
The Hacker News
C
Check Point Blog
L
Lohrmann on Cybersecurity
V2EX - 技术
V2EX - 技术
S
Securelist
T
Threat Research - Cisco Blogs
Stack Overflow Blog
Stack Overflow Blog
TaoSecurity Blog
TaoSecurity Blog
云风的 BLOG
云风的 BLOG
Latest news
Latest news
人人都是产品经理
人人都是产品经理
L
LINUX DO - 最新话题
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The Register - Security
The Register - Security
Webroot Blog
Webroot Blog
Simon Willison's Weblog
Simon Willison's Weblog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Security Blog
Microsoft Security Blog
AWS News Blog
AWS News Blog
C
Cybersecurity and Infrastructure Security Agency CISA
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
小众软件
小众软件
T
Tailwind CSS Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
宝玉的分享
宝玉的分享
O
OpenAI News

秋澪的博客

MediaWarp说明文档 | 秋澪的博客 MacBook Air M1 2025年211工科本科生体验报告 | 秋澪的博客 Conda安装以及基础使用方法 | 秋澪的博客 Fcricle踩坑记录 | 秋澪的博客 FastCDN说明文档 | 秋澪的博客 利用CloudFlare搭建镜像站 | 秋澪的博客 Docker入门教程 | 秋澪的博客 UnlockMusic音乐解锁搭建教程 | 秋澪的博客 Excalidraw搭建教程 | 秋澪的博客 AutoFilm说明文档 | 秋澪的博客 利用CDN加速并保护站点 | 秋澪的博客 校园网碎碎念 | 秋澪的博客 三朝元老再就业——百元机装机体验暨P104-100快速上手 | 秋澪的博客 将M.2固态硬盘设为群晖存储池 | 秋澪的博客 Git快速上手指南 | 秋澪的博客 利用Ventoy打造最强硬盘 | 秋澪的博客 为Hexo博客添加后台管理系统 | 秋澪的博客 MarkDown笔记软件推荐 | 秋澪的博客 免费的云数据库推荐 | 秋澪的博客 使用BetterNCM美化网易云 | 秋澪的博客 Armbian手把手玩机指南01-系统刷入并安装可视化桌面 | 秋澪的博客 IOS旧版本应用推荐 | 秋澪的博客 51单片机学习记录-01 | 秋澪的博客 51单片机学习记录-00 | 秋澪的博客 免费域名注册 | 秋澪的博客 Hexo重装记录 | 秋澪的博客 利用CloudFlare创建域名邮箱 | 秋澪的博客 在Render上部署Alist | 秋澪的博客 Docker命令大全 | 秋澪的博客 利用Replit搭建Alist | 秋澪的博客 MariaDB数据库搭建及基础用指南 | 秋澪的博客 Nginx-Proxy-Manager问题补充:DNSPod证书申请错误、NPM端口丢失 | 秋澪的博客 VPS基础配置 | 秋澪的博客 Ubuntu安装及ROS安装教程 | 秋澪的博客 个人图床搭建之Github篇 | 秋澪的博客 利用Replit搭建个人博客Halo | 秋澪的博客 AI工具网站推荐 | 秋澪的博客 MarkDown入门教程 | 秋澪的博客 基于Ubuntu安装docker | 秋澪的博客 利用FRP 和 Nginx-Proxy-Manager 为内网设备提供内外穿透服务 | 秋澪的博客 Hello World | 秋澪的博客
利用CloudFlare搭建测速网站 | 秋澪的博客
标签 · 2024-02-25 · via 秋澪的博客

此内容根据文章生成,并经过人工审核,仅用于文章内容的解释与总结

前言

有人可能会说CloudFlare在境内各种限速丢包,用CloudFlare测速怎么可能准确,但其实这个测速网站并不是平时测速用的,而是用于优选IP上的
之前写的一个小程序FastCDNFastCDN说明文档)或者使用CloudflareSpeedTest进行优选IP可能会遇到下载速度都是0MB/s,这是因为默认的测速https://cf.xiu2.xyz/url使用的人太多了,而这个测速地址也是搭建在CF Works上的,每天有一定的限额,用的人多了自然就用不了,所以这里推荐大家自建一个

测速网站原理

其实CloudflareSpeedTest对测速网站的要求很简单:

  1. 可以直接下载、文件大小超过 200MB
  2. 用的是 Cloudflare CDN
    所以我们就先找一个源下载地址,这个源地址于CloudFlare之间最好是访问通畅的(这个一般境外的网站都可以做到),然后用CF Works反代这个下载地址就好

搭建教程

登入CloudFlare账号后,在侧边栏有一个选项是Workers和Pages,点击后我们再选择创建Works
创建CF Works
然后随便设置一个名称,我这里就写speedtest,然后点击编辑代码,然后将我提供的代码复制上去

1
2
3
4
5
6
7
8
addEventListener("fetch", event => {  
let url = new URL(event.request.url);
if (url.pathname == "/" && url.search == "") {
url.href="https://download.parallels.com/desktop/v17/17.1.1-51537/ParallelsDesktop-17.1.1-51537.dmg"
let request = new Request(url, event.request);
event.respondWith(fetch(request));
}
})

配置好后回到speedtest中,点击触发器添加自定义域然后添加域名就好,这里我假设添加的是st.example.com
配置域名

尝试使用

可以尝试访问你的域名,如果跳出一个下载的文件就说明已经部署完成了,可以在FastCDN或者CloudflareSpeedTest中使用了

(设置FastCDN的配置文件)

1
2
3
setting:
CFST:
https://st.example.com/

(在CloudflareSpeedTest中使用)

1
CloudflareST -url https://st.example.com/

补充

后续我的使用改成了cmliu的方案:cmliu/CF-Workers-SpeedTestURL
并且我把代码中的并不那么准确的1000进位换成1024进位

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
export default {
  async fetch(request) {
    let url = new URL(request.url);
    let path = url.pathname.substring(1);
    let isSecure = url.protocol.startsWith("https");
    let bytes;
    if (!path) {
      bytes = 200000000;
    } else if (path === "locations") {
      let targetUrl = `http${isSecure ? 's' : ''}://speed.cloudflare.com/locations`;
      let cfRequest = new Request(targetUrl, request);
      let response = await fetch(cfRequest);
      return response;
    } else {
      const regex = /^(\d+)([a-z]?)$/i;
      const match = path.match(regex);
      if (!match) {
        return new Response("路径格式不正确", {
          status: 400,
        });
      }
      const bytesStr = match[1];
      const unit = match[2].toLowerCase();
      bytes = parseInt(bytesStr, 10);
      if (unit === "k") {
        bytes *= 1024;
      } else if (unit === "m") {
        bytes *= 1024 ** 2;
      } else if (unit === "g") {
        bytes *= 1024 ** 3;
      }
    }
    let targetUrl = `http${isSecure ? 's' : ''}://speed.cloudflare.com/__down?bytes=${bytes}`;
    let cfRequest = new Request(targetUrl, request);
    let response = await fetch(cfRequest);
    return response;
  }
};

这样就可以根据url的路径参数指定测速文件的大小,例如:

  • 1024K 测试下载地址: https://speedtest.akimio.top/1024k
  • 200M 测试下载地址: https://speedtest.akimio.top/200m
  • 1G 测试下载地址: https://speedtest.akimio.top/1g
    如果不指定则默认下载200M的文件进行测速

秋澪的博客

Akimio Blog

本文是原创文章,采用CC BY-NC-SA 4.0协议,完整转载请注明来自秋澪的博客