[{"data":1,"prerenderedAt":430},["ShallowReactive",2],{"content:\u002F2026\u002Fcf-fastip":3,"surround:\u002F2026\u002Fcf-fastip":418},{"id":4,"title":5,"body":6,"categories":391,"date":393,"description":394,"draft":395,"extension":396,"image":397,"meta":398,"navigation":400,"path":401,"permalink":402,"published":402,"readingTime":403,"recommend":402,"references":402,"seo":408,"sitemap":409,"stem":410,"tags":411,"top":395,"type":415,"updated":416,"__hash__":417},"content\u002Fposts\u002F2026\u002Fcf-fastip.md","使用CloudFlare优选任何网站！",{"type":7,"value":8,"toc":378},"minimark",[9,14,18,22,30,82,85,88,95,98,102,118,124,128,134,137,141,144,155,159,162,166,170,176,181,184,187,191,201,208,212,218,221,227,231,250,258,264,268,271,275,278,283,287,298,312,316,322,337,340,343,348,351,360],[10,11],"pic",{"caption":12,"src":13},"优选前 ITDOG IP数量","https:\u002F\u002Foss.olinl.com\u002Fcf-fastip\u002F20260622083216_5jfq.webp",[10,15],{"caption":16,"src":17},"优选后 ITDOG IP数量","https:\u002F\u002Foss.olinl.com\u002Fcf-fastip\u002F20260622083216_7g9b.webp",[19,20,21],"h2",{"id":21},"优选原理",[23,24,25,26,29],"p",{},"简单说，Cloudflare 的小黄云会同时托管两件事——DNS 解析层和路由规则层；只要开启小黄云，你就没法单独改解析、指向更快的节点。",[27,28],"br",{},"\n而 Worker 路由的出现，让规则层和解析层都可以自己配置，这就是优选能落地的关键。",[31,32,34,43,46,58,68,71,76,79],"alert",{"title":21,"type":33},"info",[23,35,36],{},[37,38,42],"a",{"href":39,"rel":40},"https:\u002F\u002F2x.nz\u002Fposts\u002Fcf-fastip\u002F#%E4%BC%98%E9%80%89%E5%8E%9F%E7%90%86",[41],"nofollow","原文：#优选原理 - 二叉树树",[23,44,45],{},"首先我们要知道 CDN 如何为不同域名分发不同内容。",[23,47,48,49,53,54,57],{},"可以将其抽象为两层：",[50,51,52],"strong",{},"规则层","和",[50,55,56],{},"解析层","。当我们普通地在 Cloudflare 添加一条开启了小黄云的解析，Cloudflare 会为我们做两件事：",[59,60,61,65],"ul",{},[62,63,64],"li",{},"写一条 DNS 解析指向 Cloudflare",[62,66,67],{},"在 Cloudflare 创建一条路由规则",[23,69,70],{},"如果想要优选，实际上就是手动更改这条 DNS 解析，使其指向一个更快的 Cloudflare 节点。但一旦关闭小黄云，路由规则也会被删除，再访问就会变成 DNS 直接指向 IP——也就用不了了。",[23,72,73],{},[50,74,75],{},"而 Worker 路由让自定义成为可能。",[23,77,78],{},"创建 Worker 路由规则（规则层）后，DNS 解析（解析层）就可以任意指向优选节点。这两件事都可以自己来做，不再依赖小黄云。",[23,80,81],{},"这就是经由 Worker 路由的流量能做优选的原因。",[19,83,84],{"id":84},"选择优选域名",[23,86,87],{},"优选的核心就是选择一个国内访问速度更快的Cloudflare节点IP或域名。",[23,89,90,91],{},"常用的社区优选域名：",[37,92,93],{"href":93,"rel":94},"https:\u002F\u002Fcf.090227.xyz",[41],[23,96,97],{},"这些优选域名通常是通过扫描Cloudflare官方IP段，找出国内延迟最低的IP整理而成。",[99,100,101],"h3",{"id":101},"使用优选域名",[23,103,104,105,112,113,117],{},"这里使用 ",[106,107,111],"tip",{":copy":108,"icon":109,"tip":110},"true","tabler:copy","复制下方内容","xxx.cf.090227.xyz","，官方推荐优先使用自定义前缀的泛域名，例如 ",[114,115,116],"code",{"code":116},"123.cf.090227.xyz","。",[23,119,120,121,117],{},"随后在你的域名 DNS 记录里添加一条 CNAME 记录，",[50,122,123],{},"不要开启小黄云",[10,125],{"caption":126,"src":127},"添加CNAME记录","https:\u002F\u002Foss.olinl.com\u002Fcf-fastip\u002F20260622083216_6q2q.webp",[23,129,130,131,133],{},"之后想给其他站点也用这个优选，把站点 CNAME 解析到上面配置好的 ",[114,132,116],{"code":116}," 即可。",[19,135,136],{"id":136},"各类优选方案",[99,138,140],{"id":139},"pageworker-项目优选","Page\u002FWorker 项目优选",[23,142,143],{},"如果你需要优选 Page\u002FWorker 项目，首先，如果你的项目是 Pages，需要先在 Pages 项目设置里迁移到 Workers。",[23,145,146,147,150,151,154],{},"接下来配置 Worker 路由：选择你的域名，路由模式填写 ",[114,148,149],{"code":149},"你的域名\u002F*","（例如 ",[114,152,153],{"code":153},"cf-blog.7o.nz\u002F*","）。",[10,156],{"caption":157,"src":158},"配置Worker路由","https:\u002F\u002Foss.olinl.com\u002Fcf-fastip\u002F20260622083216_hsdp.webp",[23,160,161],{},"最后写一条 DNS 解析到上面配置的优选域名即可。",[10,163],{"caption":164,"src":165},"配置域名优选","https:\u002F\u002Foss.olinl.com\u002Fcf-fastip\u002F20260622083216_9fjc.webp",[99,167,169],{"id":168},"worker-路由反代全球并优选","Worker 路由反代全球并优选",[171,172,173],"blockquote",{},[23,174,175],{},"本方法的原理是通过 Worker 反代源站，然后对 Worker 的入口节点做优选。这不是传统意义上的优选——源站收到的 Host 头仍是源站域名，所以源站不需要为优选域名额外配置 SSL\u002F路由。",[171,177,178],{},[23,179,180],{},"本方案可以优选Vercel，只需要将Vercel提供的域名填写进下面的配置即可。",[23,182,183],{},"点击计算 --> Wokers 和 Pages 创建应用程序 --> 从Hello Word!开始 --> 修改Worker name --> 点击部署 --> 右上角点击编辑代码，将下面代码粘贴进去，随后点击部署。",[23,185,186],{},"详情见下图：",[10,188],{"caption":189,"src":190},"创建CloudFlare Worker 并修改代码","https:\u002F\u002Foss.olinl.com\u002Fcf-fastip\u002F20260622083216_kp01.webp",[192,193,199],"pre",{"className":194,"code":196,"language":197,"meta":198},[195],"language-javascript","\n\u002F\u002F 域名前缀映射配置\n\u002F\u002F 示例：'cf-blog.7o.nz': 'cf-blog.'\n\u002F\u002F 则 Worker 路由 cf-blog.* 都会反代到 cf-blog.7o.nz\nconst domain_mappings = {\n  '源站.com': '最终访问头.',\n};\n\naddEventListener('fetch', event => {\n  event.respondWith(handleRequest(event.request));\n});\n\nasync function handleRequest(request) {\n  const url = new URL(request.url);\n  const current_host = url.host;\n\n  \u002F\u002F 强制使用 HTTPS\n  if (url.protocol === 'http:') {\n    url.protocol = 'https:';\n    return Response.redirect(url.href, 301);\n  }\n\n  const host_prefix = getProxyPrefix(current_host);\n  if (!host_prefix) {\n    return new Response('Proxy prefix not matched', { status: 404 });\n  }\n\n  \u002F\u002F 查找对应目标域名\n  let target_host = null;\n  for (const [origin_domain, prefix] of Object.entries(domain_mappings)) {\n    if (host_prefix === prefix) {\n      target_host = origin_domain;\n      break;\n    }\n  }\n\n  if (!target_host) {\n    return new Response('No matching target host for prefix', { status: 404 });\n  }\n\n  \u002F\u002F 构造目标 URL\n  const new_url = new URL(request.url);\n  new_url.protocol = 'https:';\n  new_url.host = target_host;\n\n  \u002F\u002F 创建新请求\n  const new_headers = new Headers(request.headers);\n  new_headers.set('Host', target_host);\n  new_headers.set('Referer', new_url.href);\n\n  try {\n    const response = await fetch(new_url.href, {\n      method: request.method,\n      headers: new_headers,\n      body: request.method !== 'GET' && request.method !== 'HEAD' ? request.body : undefined,\n      redirect: 'manual'\n    });\n\n    \u002F\u002F 复制响应头并添加CORS\n    const response_headers = new Headers(response.headers);\n    response_headers.set('access-control-allow-origin', '*');\n    response_headers.set('access-control-allow-credentials', 'true');\n    response_headers.set('cache-control', 'public, max-age=600');\n    response_headers.delete('content-security-policy');\n    response_headers.delete('content-security-policy-report-only');\n\n    return new Response(response.body, {\n      status: response.status,\n      statusText: response.statusText,\n      headers: response_headers\n    });\n  } catch (err) {\n    return new Response(`Proxy Error: ${err.message}`, { status: 502 });\n  }\n}\n\nfunction getProxyPrefix(hostname) {\n  for (const prefix of Object.values(domain_mappings)) {\n    if (hostname.startsWith(prefix)) {\n      return prefix;\n    }\n  }\n  return null;\n}\n\n","javascript","",[114,200,196],{"__ignoreMap":198},[23,202,203,204,207],{},"随后参考 ",[37,205,140],{"href":206},"#pageworker-%E9%A1%B9%E7%9B%AE%E4%BC%98%E9%80%89"," 进行配置即可",[99,209,211],{"id":210},"saas-外域优选","SaaS 外域优选",[23,213,214,215,217],{},"我们可以通过SaaS 自定义主机名的功能，将不属于Cloudflare的域名cname到自己的域名进行管理。",[27,216],{},"\n原理：我们将域名cname到Cloudflare边缘节点之后，Cloudflare会去寻找路由或者自定义主机名，如果寻找到了，就并入所属的配置，如果没有找到就1000。",[23,219,220],{},"这里演示Worker 绑定外部域名的路由，进行优选",[222,223,224],"ol",{},[62,225,226],{},"首先添加一个路由，域名选择你cf的域名，路由填写你的外域域名+\u002F*",[10,228],{"caption":229,"src":230},"添加外域路由","https:\u002F\u002Foss.olinl.com\u002Fcf-fastip\u002F20260622083216_jtm6.webp",[222,232,234,247],{"start":233},2,[62,235,236,237,240,241,244,246],{},"然后我们到cf域名所属的",[114,238,239],{"code":239},"SSL\u002FTLS"," ",[114,242,243],{"code":243},"自定义主机名",[27,245],{},"\n添加一个回退源，这个回退源一定要开启小黄云的才可以！",[62,248,249],{},"添加一个自定义主机名记录",[59,251,252,255],{},[62,253,254],{},"自定义主机名填写外域地址",[62,256,257],{},"证书验证方法填写HTTP验证（你已经将域名CNAME到的Cloudflare 他会自动生成http校验去帮助你完成SSL验证）",[222,259,261],{"start":260},4,[62,262,263],{},"我们将外域的域名 CNAME到你的Cloudflare 优选域名去，也就是下图这样",[10,265],{"caption":266,"src":267},"外域域名CNAME到cf cdn域名去","https:\u002F\u002Foss.olinl.com\u002Fcf-fastip\u002F20260622083216_cf42.webp",[23,269,270],{},"PS：此方法同样适用于子域",[99,272,274],{"id":273},"cloudflare-tunnel优选","CloudFlare Tunnel优选",[23,276,277],{},"我们需要开启自定义主机名SaaS功能！",[222,279,280],{},[62,281,282],{},"我们先配置2个Tunnel，指向同一个服务，一个是作为SaaS 源服务器使用，一个是最终访问优选过的站点。如下图：",[10,284],{"caption":285,"src":286},"创建Tunne","https:\u002F\u002Foss.olinl.com\u002Fcf-fastip\u002F20260622083216_g4xp.webp",[23,288,289,290,293,294,297],{},"上图中 ",[114,291,292],{"code":292},"1.oi.cd"," 作为SaaS源服务器使用，",[114,295,296],{"code":296},"2.oi.cd"," 作为优选过的站点。",[222,299,300],{"start":233},[62,301,302,303,305,306,308,309,311],{},"我们先将",[114,304,296],{"code":296}," 这个DNS记录删掉，注意！！ 这是需要到DNS记录里面删除，不要删除Tunnel！",[27,307],{},"\n然后我们添加一条",[114,310,296],{"code":296},"的优选解析，最终如下图",[10,313],{"caption":314,"src":315},"配置优选域名","https:\u002F\u002Foss.olinl.com\u002Fcf-fastip\u002F20260622083216_j14k.webp",[222,317,319],{"start":318},3,[62,320,321],{},"下面我们点击到 SSL\u002FTLS -> 自定义主机名（如果没有配置回退源，需要配置一个开启了小黄云的域名，再进行下面的操作）\n添加一条自定义主机名配置",[59,323,324,329,332],{},[62,325,326,327],{},"自定义主机名：最终访问的站点，经过优选的 ",[114,328,296],{"code":296},[62,330,331],{},"证书验证方法：HTTP验证 （因为域名在Cloudflare 他会自己验证，我们不需要进行任何解析）",[62,333,334,335],{},"自定义源服务器：填写解析记录没有动过的Tunnel，也就是",[114,336,292],{"code":292},[23,338,339],{},"保存后如下：",[10,341],{"caption":314,"src":342},"https:\u002F\u002Foss.olinl.com\u002Fcf-fastip\u002F20260622083216_u3ky.webp",[222,344,345],{"start":260},[62,346,347],{},"随后我们访问2.oi.cd即可实现优选。",[19,349,350],{"id":350},"最后",[23,352,353,354,359],{},"CloudFlare 的优选方案还有很多，外域优选、CloudFlare Tunnel 优选、CloudFlare R2 优选等，请点击",[37,355,358],{"href":356,"rel":357},"https:\u002F\u002F2x.nz\u002Fposts\u002Fcf-fastip\u002F#%E5%90%84%E7%B1%BB%E4%BC%98%E9%80%89%E6%96%B9%E6%A1%88",[41],"这里","查看更多。",[59,361,362,370],{},[62,363,364,365],{},"图文：",[37,366,369],{"href":367,"rel":368},"https:\u002F\u002F2x.nz\u002Fposts\u002Fcf-fastip\u002F",[41],"试试 Cloudflare IP 优选！让 Cloudflare 在国内再也不是减速器！ - 二叉树树",[62,371,372,373],{},"视频：",[37,374,377],{"href":375,"rel":376},"https:\u002F\u002Fwww.bilibili.com\u002Fvideo\u002FBV1QpSoBqERj",[41],"全网最全 CF 优选全解（B 站）",{"title":198,"searchDepth":260,"depth":260,"links":379},[380,381,384,390],{"id":21,"depth":233,"text":21},{"id":84,"depth":233,"text":84,"children":382},[383],{"id":101,"depth":318,"text":101},{"id":136,"depth":233,"text":136,"children":385},[386,387,388,389],{"id":139,"depth":318,"text":140},{"id":168,"depth":318,"text":169},{"id":210,"depth":318,"text":211},{"id":273,"depth":318,"text":274},{"id":350,"depth":233,"text":350},[392],"网络","2026-06-13 19:54:38","通过 Worker 反代为网站做 IP 分流优选，提高国内访问速度与可用性",false,"md","https:\u002F\u002Foss.olinl.com\u002Fcover\u002Fcf-fastip.webp",{"slots":399},{},true,"\u002F2026\u002Fcf-fastip",null,{"text":404,"minutes":405,"time":406,"words":407},"9 min read",8.205,492300,1641,{"title":5,"description":394},{"loc":401},"posts\u002F2026\u002Fcf-fastip",[412,413,414],"CloudFlare","Vercel","优选","tech","2026-06-21 16:57:55","6txt0brsSNGZhy6dAcIceSW23LvuNPIZDy_A9y0RmGo",[419,424],{"title":420,"path":421,"stem":422,"date":423,"type":415,"children":-1},"「迁」Firefly 博客部署教程","\u002F2026\u002Ffirefly-first","posts\u002F2026\u002Ffirefly-first","2026-06-12 15:46:00",{"title":425,"path":426,"stem":427,"date":428,"type":429,"children":-1},"迁移多次网站后，我回归了博客的本质","\u002F2026\u002Fless-blog","posts\u002F2026\u002Fless-blog","2026-06-23 20:13:26","story",1782231029749]