This commit is contained in:
2025-12-31 16:00:29 +00:00
commit 3688f93d5d
310 changed files with 93400 additions and 0 deletions

324
2022/11/08/cf-acc.html Normal file
View File

@@ -0,0 +1,324 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>提高Cloudflare站点在中国的体验 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="提高Cloudflare站点在中国的体验" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="从此Cloudflare不再是减速CDN了" />
<meta property="og:description" content="从此Cloudflare不再是减速CDN了" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2022-11-08T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="提高Cloudflare站点在中国的体验" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-11-08T00:00:00+08:00","datePublished":"2022-11-08T00:00:00+08:00","description":"从此Cloudflare不再是减速CDN了","headline":"提高Cloudflare站点在中国的体验","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/11/08/cf-acc.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/11/08/cf-acc.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2022/11/08/cf-acc.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2022-11-08T00:00:00+08:00">8 November 2022</time> - 字数统计2202 - 阅读大约需要7分钟 - Hits: <span id="/2022/11/08/cf-acc.html" class="visitors">Loading...</span></small>
<h1 class="p-name">提高Cloudflare站点在中国的体验</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Tue, 08 Nov 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章主要介绍了如何改善在中国使用Cloudflare服务的网站访问体验。由于中国对Cloudflare网络的某些限制用户常会遇到速度问题。文章提供了两种方法一是利用CloudflareSpeedTest工具检测最佳IP并修改 Hosts二是通过第三方反代节点这些节点可能绕过速度限制但需注意潜在的安全风险如中间人攻击和匿名性导致的防火墙失效。对于网站站长云flare官方的新CNAME接入方式允许绑定信用卡进行限制性接入通过设置不重要的域名作为跳板可灵活选择节点以优化访问速度但需开启证书透明度监视以防止中间人攻击。作者还提到可以考虑使用DDNS脚本来自动调整IP但缺乏实操条件。文章最后表达了对Cloudflare优化服务的肯定。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#普通用户的解决方法">普通用户的解决方法</a></li><li><a href="#对于站长的解决方法">对于站长的解决方法</a></li><li><a href="#感想">感想</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>从此Cloudflare不再是减速CDN了<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>众所周知因为很多人用Cloudflare当作梯子中转之类的原因中国对Cloudflare网络的速度会有很大程度的劣化所以在上面的网站访问速度也会非常烂。最近我发现了一个不错的办法可以在一定程度上避免这个问题所以今天就来说一说。</p>
<h1 id="普通用户的解决方法">
<a href="#普通用户的解决方法"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 普通用户的解决方法
</h1>
<p>对于网站的访问者来说,使用<a href="https://github.com/XIU2/CloudflareSpeedTest">CloudflareSpeedTest</a>这个工具就挺不错的它能检测到当前网络连哪个IP是最好的。因为Cloudflare网络用的是Anycast无论从哪个IP进入都可以所以用这个检测出来的IP直接改Hosts访问就能解决访问网站慢的问题。 </p><p>
不过有些地区可能是服务商主动对Cloudflare的IP段进行限速那这样有可能测试出来没有可以使用的节点那么还有一种方法网络上有些可能是企业之类的人会反代Cloudflare的网站用于解决在国内访问慢的问题并且没有对host头做限制那么这些第三方的节点同样也可以作为访问Cloudflare网站的方法。具体怎么找到这样的IP有一个<a href="https://github.com/ip-scanner/cloudflare">仓库</a>每天都会扫描全网去找像这样的节点。 </p><p>
当然这些节点也不是所有的IP从中国连接速度都很好这时候可以把这个仓库的所有IP收集起来然后再丢给CloudflareSpeedTest去测试具体我写了个简单的脚本来处理</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone https://github.com/ip-scanner/cloudflare.git
<span class="nb">cat </span>cloudflare/<span class="k">*</span>.txt <span class="o">&gt;</span> proxy.txt
./CloudflareST <span class="nt">-allip</span> <span class="nt">-sl</span> 0.1 <span class="nt">-f</span> proxy.txt <span class="nt">-n</span> 500
</code></pre></div></div>
<p>这样获得的第三方IP就基本上不会被限速里面甚至有可能有通过IPLC或者IEPL的节点包括拿来当梯子中转速度都几乎可以跑满带宽另外还有一个优点是这样Cloudflare获得的IP就是第三方节点的IP可以起到匿名的作用。</p>
<h1 id="对于站长的解决方法">
<a href="#对于站长的解决方法"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 对于站长的解决方法
</h1>
<p>上面的方法相当于是用户自己去解决访问的问题但是操作可能还是会有点复杂所以对于网站站长来说不可能去期待访客通过这种方法来提高访问自己网站的速度。不过Cloudflare网站接入只能通过NS方式接入这样接入的话域名解析的IP就是自动分配的没办法自己设定解析也就不能选择更合适的IP另外之前用CF Partner通过CNAME接入的方法基本上都全死光了那现在应该怎么办呢后来我搜了一下Cloudflare原来已经提供了官方通过CNAME接入的方法应该是新加的功能除了要绑信用卡之外就没别的要求了。 </p><p>
在使用这个功能之前必须先有2个域名一个是不重要的域名通过NS方式接入Cloudflare另一个是主要使用的域名可以接到Cloudflare上也可以接到别的NS服务商上。然后在那个不重要的域名中先设定好源站的解析可以解析到“@”或者随便一个二级域名也可以并且打开代理。然后点开SSL/TLS-&gt;自定义主机名第一次使用需要绑定信用卡或者PayPal好像是因为它是个什么预付费的项目免费100个CNAME超过100个每个0.1USD。打开以后在回退源中输入刚刚设置好解析的那个域名当回退源状态显示有效后就可以添加自定义主机名了。这里添加的主机名就是主要使用的域名输入后根据提示在主域名上设定好TXT记录完成后只要看到刚刚设定的主机名后面跟了两个有效就可以了。 </p><p>
这样准备工作就做完了现在只要把主域名的解析设定到Cloudflare网络的任意节点它就会自动连接到不重要的域名所解析的IP上。至于怎么获得优秀的IP就可以像普通用户那样操作了获得优秀的IP以后我们就可以设定一个A记录解析过去。 </p><p>
不过这里需要注意一些地方如果使用的优选IP是Cloudflare官方的IP那基本上也不会有什么问题只是这个IP可能有些地区还是会访问缓慢毕竟它也算是在重点关注对象中。如果是选择第三方节点IP大多数情况速度都能保障但是有个很大的问题就是那些节点的主人如果发现了你在使用他们的节点他们是可以很轻易的进行中间人攻击的毕竟域名都解析过去了整个SSL证书也很简单为了能避免这个问题一定要开启“证书透明度监视”保证能在第一时间避免有人进行中间人攻击。另外还有一个问题就是既然第三方IP可以匿名那么网站也没办法获取到用户的真实IP地址了像Cloudflare一些根据IP的防火墙也会无法生效像WAF中的速率限制规则是万万不能开的开了很大可能网站就访问不了了。还有就是DDoS是可以击垮第三方节点的可能会使网站的可用性下降。所以如果对速度没有特别在意的情况下还是解析到官方IP上更好一些。 </p><p>
所以为了避免节点可能会用不了的情况我有个想法因为我没有大陆地区的服务器所以只是设想之前我用过一个可以给Cloudflare设定DDNS的脚本<a href="https://github.com/aipeach/cloudflare-api-v4-ddns">cloudflare-api-v4-ddns</a>原本它是去请求获取本机IP的API设定解析的那么如果把上面优选IP的结果输入到这个脚本中放到国内的服务器上每天自动执行一次那这样我的网站不就会一直使用最优秀的IP了嘛可惜我没有国内的服务器改起来还要费点事就算了吧。</p>
<h1 id="感想">
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
</h1>
<p>有了很多辅助的工具能让Cloudflare不再成为减速CDN那它岂不是可以吊打国内其他CDN厂商了😆果然还是良心厂商啊。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=Cloudflare"><em>Cloudflare</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%8A%A0%E9%80%9F"><em>加速</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-11-08-cf-acc.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2022/11/08/cf-acc.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2022/10/19/web3.html">
上一篇在Web3上搭建一个自己的博客
</a>
</span>
<br />
<span class="next">
<a href="/2022/11/16/tor.html">
下一篇Tor在服务器上的使用体验
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2022/11/08/cf-acc', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2022/11/08/cf-acc.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>