<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <author>
    <name>卡泽</name>
  </author>
  <generator uri="https://hexo.io/">Hexo</generator>
  <id>https://passage.kaze.zone/</id>
  <link href="https://passage.kaze.zone/" rel="alternate"/>
  <link href="https://passage.kaze.zone/atom.xml" rel="self"/>
  <rights>All rights reserved 2026, 卡泽</rights>
  <subtitle>持续输入，向上生长。</subtitle>
  <title>Kaze's Home</title>
  <updated>2026-04-30T04:40:28.550Z</updated>
  <entry>
    <author>
      <name>卡泽</name>
    </author>
    <category term="项目实战" scheme="https://passage.kaze.zone/categories/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/"/>
    <category term="Cloudflare Workers" scheme="https://passage.kaze.zone/tags/Cloudflare-Workers/"/>
    <category term="busuanzi" scheme="https://passage.kaze.zone/tags/busuanzi/"/>
    <content>
      <![CDATA[<p>不蒜子这服务吧，好用是好用，就是经常挂。挂了之后博客底下的访问量就一直在那转圈圈，看着心烦。与其天天等它恢复，不如自己整一个，反正 Cloudflare Workers 免费额度够用，KV 也白给。</p><p>于是就有了这个项目：<a href="https://github.com/kazeecho/busuanzi-cloudflare-workers">busuanzi-cloudflare-workers</a>。</p><h2 id="一、这玩意儿是啥"><a href="#一、这玩意儿是啥" class="headerlink" title="一、这玩意儿是啥"></a>一、这玩意儿是啥</h2><p>简单说，就是一个部署在 Cloudflare Workers 上的访问统计服务，拿来替代不蒜子。</p><p>核心功能：</p><ul><li>站点&#x2F;页面的 PV（访问量）和 UV（访客数）统计</li><li>今日数据也能统计</li><li>兼容原版不蒜子的标签 ID，换个脚本地址就能直接用</li><li>JSONP 接口也支持</li><li>隐私友好：只存 IP 的 SHA-256 哈希，原始 IP 不记录</li><li>Pjax &#x2F; swup 页面切换自动支持</li></ul><p>说白了，就是不想再被不蒜子的稳定性绑架了 QWQ</p><h2 id="二、怎么部署"><a href="#二、怎么部署" class="headerlink" title="二、怎么部署"></a>二、怎么部署</h2><h3 id="第一步：克隆项目"><a href="#第一步：克隆项目" class="headerlink" title="第一步：克隆项目"></a>第一步：克隆项目</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git <span class="built_in">clone</span> https://github.com/kazeecho/busuanzi-cloudflare-workers.git</span><br><span class="line"><span class="built_in">cd</span> busuanzi-cloudflare-workers</span><br><span class="line">npm install</span><br></pre></td></tr></table></figure><h3 id="第二步：创建-KV-命名空间"><a href="#第二步：创建-KV-命名空间" class="headerlink" title="第二步：创建 KV 命名空间"></a>第二步：创建 KV 命名空间</h3><p>KV 是 Cloudflare 提供的键值存储，咱们拿它来存计数数据。</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npx wrangler kv namespace create BUSUANZI_KV</span><br></pre></td></tr></table></figure><p>跑完会输出一段配置，把那个 <code>id</code> 填到 <code>wrangler.toml</code> 里就行：</p><figure class="highlight toml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">[[kv_namespaces]]</span></span><br><span class="line"><span class="attr">binding</span> = <span class="string">&quot;BUSUANZI_KV&quot;</span></span><br><span class="line"><span class="attr">id</span> = <span class="string">&quot;刚才输出的那个 id&quot;</span></span><br></pre></td></tr></table></figure><h3 id="第三步：配置密钥"><a href="#第三步：配置密钥" class="headerlink" title="第三步：配置密钥"></a>第三步：配置密钥</h3><p>改一下 <code>wrangler.toml</code> 里的 <code>SALT_SECRET</code>，随便填个随机字符串：</p><figure class="highlight toml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">[vars]</span></span><br><span class="line"><span class="attr">SALT_SECRET</span> = <span class="string">&quot;随便来一串&quot;</span></span><br></pre></td></tr></table></figure><p>或者用命令行设置（更安全，密钥不会明文出现在配置文件里）：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npx wrangler secret put SALT_SECRET</span><br></pre></td></tr></table></figure><blockquote><p>这个密钥是用来给 UV 去重哈希加盐的，别填太简单的。</p></blockquote><h3 id="第四步：部署"><a href="#第四步：部署" class="headerlink" title="第四步：部署"></a>第四步：部署</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm run deploy</span><br></pre></td></tr></table></figure><p>完事，你的 Worker 就上线了。</p><h2 id="三、怎么用"><a href="#三、怎么用" class="headerlink" title="三、怎么用"></a>三、怎么用</h2><h3 id="方式一：嵌入脚本（最省心）"><a href="#方式一：嵌入脚本（最省心）" class="headerlink" title="方式一：嵌入脚本（最省心）"></a>方式一：嵌入脚本（最省心）</h3><p>跟原版不蒜子用法一模一样，就换个脚本地址：</p><figure class="highlight diff"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="deletion">- &lt;script src=&quot;//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js&quot; defer&gt;&lt;/script&gt;</span></span><br><span class="line"><span class="addition">+ &lt;script src=&quot;https://your-worker.workers.dev/busuanzi.js&quot; defer&gt;&lt;/script&gt;</span></span><br></pre></td></tr></table></figure><p>然后 HTML 里这些标签不用动，直接就能用：</p><table><thead><tr><th>标签 ID</th><th>说明</th></tr></thead><tbody><tr><td><code>busuanzi_site_pv</code></td><td>全站总访问量</td></tr><tr><td><code>busuanzi_site_uv</code></td><td>全站总访客数</td></tr><tr><td><code>busuanzi_page_pv</code></td><td>单页面阅读量</td></tr><tr><td><code>busuanzi_page_uv</code></td><td>单页面访客数</td></tr><tr><td><code>busuanzi_today_pv</code></td><td>今日全站访问量</td></tr><tr><td><code>busuanzi_today_uv</code></td><td>今日全站访客数</td></tr></tbody></table><p>零修改迁移，舒舒服服。</p><h3 id="方式二：直接调-API"><a href="#方式二：直接调-API" class="headerlink" title="方式二：直接调 API"></a>方式二：直接调 API</h3><p>想自己控制请求逻辑的，可以直接调接口：</p><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 提交访问并获取数据</span></span><br><span class="line"><span class="title function_">fetch</span>(<span class="string">&quot;https://your-worker.workers.dev/api&quot;</span>, &#123;</span><br><span class="line">  <span class="attr">method</span>: <span class="string">&quot;POST&quot;</span>,</span><br><span class="line">  <span class="attr">headers</span>: &#123; <span class="string">&quot;x-bsz-referer&quot;</span>: <span class="variable language_">window</span>.<span class="property">location</span>.<span class="property">href</span> &#125;,</span><br><span class="line">&#125;)</span><br><span class="line">  .<span class="title function_">then</span>(<span class="function">(<span class="params">res</span>) =&gt;</span> res.<span class="title function_">json</span>())</span><br><span class="line">  .<span class="title function_">then</span>(<span class="function">(<span class="params">data</span>) =&gt;</span> <span class="variable language_">console</span>.<span class="title function_">log</span>(data));</span><br><span class="line"></span><br><span class="line"><span class="comment">// 只看不计数</span></span><br><span class="line"><span class="title function_">fetch</span>(<span class="string">&quot;https://your-worker.workers.dev/api&quot;</span>, &#123;</span><br><span class="line">  <span class="attr">headers</span>: &#123; <span class="string">&quot;Referer&quot;</span>: <span class="variable language_">window</span>.<span class="property">location</span>.<span class="property">href</span> &#125;,</span><br><span class="line">&#125;)</span><br><span class="line">  .<span class="title function_">then</span>(<span class="function">(<span class="params">res</span>) =&gt;</span> res.<span class="title function_">json</span>())</span><br><span class="line">  .<span class="title function_">then</span>(<span class="function">(<span class="params">data</span>) =&gt;</span> <span class="variable language_">console</span>.<span class="title function_">log</span>(data));</span><br></pre></td></tr></table></figure><h3 id="方式三：JSONP"><a href="#方式三：JSONP" class="headerlink" title="方式三：JSONP"></a>方式三：JSONP</h3><p>老项目兼容需要 JSONP 的也支持：</p><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">script</span>&gt;</span><span class="language-javascript"></span></span><br><span class="line"><span class="language-javascript"><span class="keyword">function</span> <span class="title function_">busuanziCallback</span>(<span class="params">data</span>) &#123;</span></span><br><span class="line"><span class="language-javascript">  <span class="variable language_">document</span>.<span class="title function_">getElementById</span>(<span class="string">&quot;my-pv&quot;</span>).<span class="property">textContent</span> = data.<span class="property">page_pv</span>;</span></span><br><span class="line"><span class="language-javascript">&#125;</span></span><br><span class="line"><span class="language-javascript"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;https://your-worker.workers.dev/jsonp?callback=busuanziCallback&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br></pre></td></tr></table></figure><p>详细的接口文档看这里：<a href="https://github.com/kazeecho/busuanzi-cloudflare-workers/blob/main/API.md">API.md</a></p><h2 id="四、几个要注意的点"><a href="#四、几个要注意的点" class="headerlink" title="四、几个要注意的点"></a>四、几个要注意的点</h2><h3 id="KV-并发计数"><a href="#KV-并发计数" class="headerlink" title="KV 并发计数"></a>KV 并发计数</h3><p>KV 不支持原子 increment，<code>get → +1 → put</code> 在高并发时可能丢几个计数。不过博客这种量级，一天能有几个并发？完全不用担心。</p><h3 id="UV-归档"><a href="#UV-归档" class="headerlink" title="UV 归档"></a>UV 归档</h3><p>Cron Trigger 每天 UTC 00:05 跑一次归档，把昨天的 UV 加到累计值。记得确认 Worker 的 Cron Triggers 是开着的，不然 UV 数据会一直停留在昨天的当日值上。</p><h3 id="花多少钱"><a href="#花多少钱" class="headerlink" title="花多少钱"></a>花多少钱</h3><table><thead><tr><th>资源</th><th>免费额度</th><th>博客大概用量</th></tr></thead><tbody><tr><td>Worker 请求</td><td>100,000 次&#x2F;天</td><td>~200 次&#x2F;天</td></tr><tr><td>KV 读取</td><td>100,000 次&#x2F;天</td><td>~200 次&#x2F;天</td></tr><tr><td>KV 写入</td><td>1,000 次&#x2F;天</td><td>~200 次&#x2F;天</td></tr><tr><td>Cron 触发</td><td>5 次&#x2F;天</td><td>1 次&#x2F;天</td></tr></tbody></table><p>免费额度完全够用，放心部署。</p><h3 id="历史数据"><a href="#历史数据" class="headerlink" title="历史数据"></a>历史数据</h3><p>历史数据没法从不蒜子搬过来，统计会从零开始。反正也不是啥大事，重新攒呗（雾</p><h2 id="五、UV-去重是怎么搞的"><a href="#五、UV-去重是怎么搞的" class="headerlink" title="五、UV 去重是怎么搞的"></a>五、UV 去重是怎么搞的</h2><p>简单说就是：<code>sha256(IP + 当日日期 + 密钥)</code>。</p><ul><li>同一个 IP 同一天访问多次只算 1 次</li><li>哈希值没法反推出原始 IP，不侵犯隐私</li><li>每天的去重 key 48 小时后自动过期清理</li></ul><p>所以你不用担心 IP 泄露的问题，存下来的只是一串不可逆的哈希值。</p><h2 id="结语"><a href="#结语" class="headerlink" title="结语"></a>结语</h2><p>自建统计服务的好处就是它不会再突然挂掉了（除非 Cloudflare 挂，那咱也没办法）。而且数据在自己手里，想怎么查就怎么查。</p><p>项目地址：<a href="https://github.com/kazeecho/busuanzi-cloudflare-workers">busuanzi-cloudflare-workers</a></p><p>给孩子点个 star 吧，球球了 🙏</p>]]>
    </content>
    <id>https://passage.kaze.zone/posts/busuanzi-cloudflare-workers/</id>
    <link href="https://passage.kaze.zone/posts/busuanzi-cloudflare-workers/"/>
    <published>2026-04-29T15:00:00.000Z</published>
    <summary>
      <![CDATA[<p>不蒜子这服务吧，好用是好用，就是经常挂。挂了之后博客底下的访问量就一直在那转圈圈，看着心烦。与其天天等它恢复，不如自己整一个，反正 Cloudflare Workers 免费额度够用，KV 也白给。</p>
<p>于是就有了这个项目：<a href="https://git]]>
    </summary>
    <title>来给自己整一个山寨不蒜子（Bushi</title>
    <updated>2026-04-30T04:40:28.550Z</updated>
  </entry>
  <entry>
    <author>
      <name>卡泽</name>
    </author>
    <category term="折腾记录" scheme="https://passage.kaze.zone/categories/%E6%8A%98%E8%85%BE%E8%AE%B0%E5%BD%95/"/>
    <category term="Cloudflare Workers" scheme="https://passage.kaze.zone/tags/Cloudflare-Workers/"/>
    <category term="Google卫星地图" scheme="https://passage.kaze.zone/tags/Google%E5%8D%AB%E6%98%9F%E5%9C%B0%E5%9B%BE/"/>
    <category term="奥维互动地图" scheme="https://passage.kaze.zone/tags/%E5%A5%A5%E7%BB%B4%E4%BA%92%E5%8A%A8%E5%9C%B0%E5%9B%BE/"/>
    <category term="反代" scheme="https://passage.kaze.zone/tags/%E5%8F%8D%E4%BB%A3/"/>
    <content>
      <![CDATA[<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>有没有发现咱们国内的卫星地图放大到一定程度就”糊”了？想看看自家位置？不好意思，看不清… </p><p>别慌：用 Cloudflare Workers（免费的！）反代 Google Map，然后导入奥维互动地图，轻轻松松看高清卫星图！</p><h2 id="为什么想用-Google-卫星图？"><a href="#为什么想用-Google-卫星图？" class="headerlink" title="为什么想用 Google 卫星图？"></a>为什么想用 Google 卫星图？</h2><p>原因很简单：</p><ol><li><strong>境内卫图太糊</strong>：放大后就一片模糊，细节啥的根本看不到</li><li><strong>Google 卫星图不错</strong>：但问题是被限制了，直接访问不了</li></ol><p>所以咱们今天的目标就是：<strong>用反代绕过这个限制，让奥维互动地图能加载 Google 的高清卫星图</strong>。</p><h2 id="一、先把家伙准备好"><a href="#一、先把家伙准备好" class="headerlink" title="一、先把家伙准备好"></a>一、先把家伙准备好</h2><p>工欲善其事，必先利其器。咱们需要这几样东西：</p><ul><li><strong>奥维互动地图</strong>：没安装的话去官网下一个，这个软件挺不错的，支持多种地图源</li><li><strong>一个 Cloudflare 账号</strong>：免费的！每天 10 万次调用额度，够用了</li><li><strong>一个自己的域名</strong>：这个必须有！不然 workers.dev 在国内用不了</li></ul><blockquote><p><strong>注意</strong>：Cloudflare Workers 的 *.workers.dev 域名在国内已经被 DNS 污染了，<strong>必须使用自定义域名</strong>才能正常访问。</p></blockquote><h2 id="二、创建-Cloudflare-Workers"><a href="#二、创建-Cloudflare-Workers" class="headerlink" title="二、创建 Cloudflare Workers"></a>二、创建 Cloudflare Workers</h2><h3 id="1-注册-Cloudflare-账号"><a href="#1-注册-Cloudflare-账号" class="headerlink" title="1. 注册 Cloudflare 账号"></a>1. 注册 Cloudflare 账号</h3><ol><li>打开 <a href="https://dash.cloudflare.com/sign-up">Cloudflare 注册页面</a></li><li>用邮箱注册，选免费计划就行</li></ol><h3 id="2-创建-Worker（网页操作）"><a href="#2-创建-Worker（网页操作）" class="headerlink" title="2. 创建 Worker（网页操作）"></a>2. 创建 Worker（网页操作）</h3><ol><li>进入 <a href="https://dash.cloudflare.com/">Cloudflare 控制台</a></li><li>点左侧菜单的 <strong>计算</strong> → <strong>Workers &amp; Pages</strong></li><li>点 <strong>创建应用程序</strong></li><li>选择 <strong>从 Hello World 开始</strong></li><li>点 <strong>部署</strong></li><li>部署完成后点 <strong>编辑代码</strong>，把反代代码复制进去（后面会讲）</li></ol><h3 id="3-绑定自定义域名（必须！）"><a href="#3-绑定自定义域名（必须！）" class="headerlink" title="3. 绑定自定义域名（必须！）"></a>3. 绑定自定义域名（必须！）</h3><p><strong>前置条件</strong>：你的域名需要先托管到 Cloudflare。</p><ol><li>进入 <a href="https://dash.cloudflare.com/">Cloudflare 控制台</a>，点击左侧 <strong>网站</strong></li><li>点 <strong>添加站点</strong>，按提示把你的域名托管到 Cloudflare</li><li>在你的域名服务商那里，按照 Cloudflare 给出的 NS 服务器地址修改域名的 DNS 服务器</li></ol><p><strong>开始绑定域名到 Worker</strong>：</p><ol start="4"><li>域名托管完成后，点左侧菜单的 <strong>计算</strong> → <strong>Workers &amp; Pages</strong></li><li>点击你刚创建的 Worker</li><li>点 <strong>设置</strong> → <strong>域和路由</strong> → <strong>自定义域</strong></li><li>点 <strong>添加自定义域</strong></li><li>填入你的域名，比如 <code>map.yourdomain.com</code></li><li>等待 DNS 生效（约几分钟到几小时）</li></ol><h2 id="三、部署反代代码"><a href="#三、部署反代代码" class="headerlink" title="三、部署反代代码"></a>三、部署反代代码</h2><h3 id="1-替换代码"><a href="#1-替换代码" class="headerlink" title="1. 替换代码"></a>1. 替换代码</h3><p>用下面这个反代代码替换刚才创建 Worker 时的默认代码（即「二、创建 Cloudflare Workers」中第 2 步第 6 点打开的编辑器里的内容）：</p><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> upstream = <span class="string">&#x27;mt1.google.com&#x27;</span></span><br><span class="line"><span class="keyword">const</span> blocked_ip_address = [<span class="string">&#x27;0.0.0.0&#x27;</span>, <span class="string">&#x27;127.0.0.1&#x27;</span>]</span><br><span class="line"><span class="keyword">const</span> replace_dict = &#123;</span><br><span class="line">    <span class="string">&#x27;$upstream&#x27;</span>: <span class="string">&#x27;$custom_domain&#x27;</span>,</span><br><span class="line">    <span class="string">&#x27;//mt1.google.com&#x27;</span>: <span class="string">&#x27;&#x27;</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="title function_">addEventListener</span>(<span class="string">&#x27;fetch&#x27;</span>, <span class="function"><span class="params">event</span> =&gt;</span>&#123;</span><br><span class="line">    event.<span class="title function_">respondWith</span>(<span class="title function_">fetchAndApply</span>(event.<span class="property">request</span>));</span><br><span class="line">&#125;)</span><br><span class="line"><span class="keyword">async</span> <span class="keyword">function</span> <span class="title function_">fetchAndApply</span>(<span class="params">request</span>) &#123;</span><br><span class="line">    <span class="keyword">const</span> ip_address = request.<span class="property">headers</span>.<span class="title function_">get</span>(<span class="string">&#x27;cf-connecting-ip&#x27;</span>);</span><br><span class="line">    <span class="keyword">const</span> user_agent = request.<span class="property">headers</span>.<span class="title function_">get</span>(<span class="string">&#x27;user-agent&#x27;</span>);</span><br><span class="line">    <span class="keyword">let</span> response = <span class="literal">null</span>;</span><br><span class="line">    <span class="keyword">let</span> url = <span class="keyword">new</span> <span class="title function_">URL</span>(request.<span class="property">url</span>);</span><br><span class="line">    <span class="keyword">let</span> url_host = url.<span class="property">host</span>;</span><br><span class="line">    <span class="keyword">if</span> (url.<span class="property">protocol</span> == <span class="string">&#x27;http:&#x27;</span>) &#123;</span><br><span class="line">        url.<span class="property">protocol</span> = <span class="string">&#x27;https:&#x27;</span></span><br><span class="line">        response = <span class="title class_">Response</span>.<span class="title function_">redirect</span>(url.<span class="property">href</span>);</span><br><span class="line">        <span class="keyword">return</span> response;</span><br><span class="line">    &#125;</span><br><span class="line">    url.<span class="property">host</span> = upstream;</span><br><span class="line">    <span class="keyword">if</span> (blocked_ip_address.<span class="title function_">includes</span>(ip_address)) &#123;</span><br><span class="line">        response = <span class="keyword">new</span> <span class="title class_">Response</span>(<span class="string">&#x27;Access denied: Your IP address is blocked by WorkersProxy.&#x27;</span>, &#123;</span><br><span class="line">            <span class="attr">status</span>: <span class="number">403</span></span><br><span class="line">        &#125;);</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        <span class="keyword">let</span> method = request.<span class="property">method</span>;</span><br><span class="line">        <span class="keyword">let</span> request_headers = request.<span class="property">headers</span>;</span><br><span class="line">        <span class="keyword">let</span> new_request_headers = <span class="keyword">new</span> <span class="title class_">Headers</span>(request_headers);</span><br><span class="line">        new_request_headers.<span class="title function_">set</span>(<span class="string">&#x27;Host&#x27;</span>, upstream);</span><br><span class="line">        new_request_headers.<span class="title function_">set</span>(<span class="string">&#x27;Referer&#x27;</span>, url.<span class="property">href</span>);</span><br><span class="line">        <span class="keyword">let</span> original_response = <span class="keyword">await</span> <span class="title function_">fetch</span>(url.<span class="property">href</span>, &#123;</span><br><span class="line">            <span class="attr">method</span>: method,</span><br><span class="line">            <span class="attr">headers</span>: new_request_headers</span><br><span class="line">        &#125;)</span><br><span class="line">        <span class="keyword">let</span> original_response_clone = original_response.<span class="title function_">clone</span>();</span><br><span class="line">        <span class="keyword">let</span> original_text = <span class="literal">null</span>;</span><br><span class="line">        <span class="keyword">let</span> response_headers = original_response.<span class="property">headers</span>;</span><br><span class="line">        <span class="keyword">let</span> new_response_headers = <span class="keyword">new</span> <span class="title class_">Headers</span>(response_headers);</span><br><span class="line">        <span class="keyword">let</span> status = original_response.<span class="property">status</span>;</span><br><span class="line">        new_response_headers.<span class="title function_">set</span>(<span class="string">&#x27;access-control-allow-origin&#x27;</span>, <span class="string">&#x27;*&#x27;</span>);</span><br><span class="line">        new_response_headers.<span class="title function_">set</span>(<span class="string">&#x27;access-control-allow-credentials&#x27;</span>, <span class="literal">true</span>);</span><br><span class="line">        new_response_headers.<span class="title function_">delete</span>(<span class="string">&#x27;content-security-policy&#x27;</span>);</span><br><span class="line">        new_response_headers.<span class="title function_">delete</span>(<span class="string">&#x27;content-security-policy-report-only&#x27;</span>);</span><br><span class="line">        new_response_headers.<span class="title function_">delete</span>(<span class="string">&#x27;clear-site-data&#x27;</span>);</span><br><span class="line">        <span class="keyword">const</span> content_type = new_response_headers.<span class="title function_">get</span>(<span class="string">&#x27;content-type&#x27;</span>);</span><br><span class="line">        <span class="keyword">if</span> (content_type.<span class="title function_">includes</span>(<span class="string">&#x27;text/html&#x27;</span>) &amp;&amp; content_type.<span class="title function_">includes</span>(<span class="string">&#x27;UTF-8&#x27;</span>)) &#123;</span><br><span class="line">            original_text = <span class="keyword">await</span> <span class="title function_">replace_response_text</span>(original_response_clone, upstream, url_host);</span><br><span class="line">        &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">            original_text = original_response_clone.<span class="property">body</span></span><br><span class="line">        &#125;</span><br><span class="line">        response = <span class="keyword">new</span> <span class="title class_">Response</span>(original_text, &#123;</span><br><span class="line">            status,</span><br><span class="line">            <span class="attr">headers</span>: new_response_headers</span><br><span class="line">        &#125;)</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> response;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">async</span> <span class="keyword">function</span> <span class="title function_">replace_response_text</span>(<span class="params">response, upstream, host_name</span>) &#123;</span><br><span class="line">    <span class="keyword">let</span> text = <span class="keyword">await</span> response.<span class="title function_">text</span>()</span><br><span class="line">    <span class="keyword">var</span> i, j;</span><br><span class="line">    <span class="keyword">for</span> (i <span class="keyword">in</span> replace_dict) &#123;</span><br><span class="line">        j = replace_dict[i]</span><br><span class="line">        <span class="keyword">if</span> (i == <span class="string">&#x27;$upstream&#x27;</span>) &#123;</span><br><span class="line">            i = upstream</span><br><span class="line">        &#125; <span class="keyword">else</span> <span class="keyword">if</span> (i == <span class="string">&#x27;$custom_domain&#x27;</span>) &#123;</span><br><span class="line">            i = host_name</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span> (j == <span class="string">&#x27;$upstream&#x27;</span>) &#123;</span><br><span class="line">            j = upstream</span><br><span class="line">        &#125; <span class="keyword">else</span> <span class="keyword">if</span> (j == <span class="string">&#x27;$custom_domain&#x27;</span>) &#123;</span><br><span class="line">            j = host_name</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">let</span> re = <span class="keyword">new</span> <span class="title class_">RegExp</span>(i, <span class="string">&#x27;g&#x27;</span>)</span><br><span class="line">        text = text.<span class="title function_">replace</span>(re, j);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> text;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">async</span> <span class="keyword">function</span> <span class="title function_">device_status</span>(<span class="params">user_agent_info</span>) &#123;</span><br><span class="line">    <span class="keyword">var</span> agents = [<span class="string">&quot;Android&quot;</span>, <span class="string">&quot;iPhone&quot;</span>, <span class="string">&quot;SymbianOS&quot;</span>, <span class="string">&quot;Windows Phone&quot;</span>, <span class="string">&quot;iPad&quot;</span>, <span class="string">&quot;iPod&quot;</span>];</span><br><span class="line">    <span class="keyword">var</span> flag = <span class="literal">true</span>;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">var</span> v = <span class="number">0</span>; v &lt; agents.<span class="property">length</span>; v++) &#123; <span class="keyword">if</span> (user_agent_info.<span class="title function_">indexOf</span>(agents[v]) &gt; <span class="number">0</span>) &#123;</span><br><span class="line">            flag = <span class="literal">false</span>;</span><br><span class="line">            <span class="keyword">break</span>;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> flag;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><p>部署成功后，你的反代地址就是你绑定的自定义域名，比如 <code>https://map.yourdomain.com</code>。</p><h2 id="四、在奥维互动地图里配置"><a href="#四、在奥维互动地图里配置" class="headerlink" title="四、在奥维互动地图里配置"></a>四、在奥维互动地图里配置</h2><p>这是重头戏！打开奥维互动地图，按以下步骤操作：</p><h3 id="1-添加自定义地图"><a href="#1-添加自定义地图" class="headerlink" title="1. 添加自定义地图"></a>1. 添加自定义地图</h3><ol><li>点击左上角 <strong>菜单</strong> → <strong>系统设置</strong></li><li>找到 <strong>地图设置</strong> → <strong>自定义地图</strong></li><li>点击 <strong>添加</strong></li></ol><h3 id="2-填写配置信息"><a href="#2-填写配置信息" class="headerlink" title="2. 填写配置信息"></a>2. 填写配置信息</h3><p>按照下表填写（注意把域名改成你自己的）：</p><table><thead><tr><th>配置项</th><th>填什么</th></tr></thead><tbody><tr><td><strong>地图名称</strong></td><td>Google卫星图（反代）</td></tr><tr><td><strong>协议</strong></td><td>https</td></tr><tr><td><strong>主机名</strong></td><td>你的自定义域名，比如 <code>map.yourdomain.com</code></td></tr><tr><td><strong>端口号</strong></td><td>443</td></tr><tr><td><strong>最大级别</strong></td><td>20</td></tr><tr><td><strong>投影类型</strong></td><td>墨卡托中国</td></tr><tr><td><strong>图片格式</strong></td><td>PNG</td></tr><tr><td><strong>图片大小</strong></td><td>256像素</td></tr><tr><td><strong>图片类型</strong></td><td>影像地图</td></tr></tbody></table><h3 id="3-URL-模板"><a href="#3-URL-模板" class="headerlink" title="3. URL 模板"></a>3. URL 模板</h3><p>奥维支持的 Google 地图 URL 有好几种，根据自己需求选：</p><table><thead><tr><th>地图类型</th><th>URL 模板</th><th>说明</th></tr></thead><tbody><tr><td><strong>卫星影像图</strong></td><td><code>/vt/lyrs=s@699&amp;hl=zh-CN&amp;gl=cn&amp;src=app&amp;x=&#123;$x&#125;&amp;y=&#123;$y&#125;&amp;z=&#123;$z&#125;&amp;s=</code></td><td>纯卫星影像，无路网</td></tr><tr><td><strong>卫星+路网</strong></td><td><code>/vt/lyrs=s,m@699&amp;hl=zh-CN&amp;gl=cn&amp;src=app&amp;x=&#123;$x&#125;&amp;y=&#123;$y&#125;&amp;z=&#123;$z&#125;&amp;s=</code></td><td>影像+路网叠加</td></tr><tr><td><strong>路网小字体</strong></td><td><code>/vt/imgtp=png32&amp;lyrs=h@292000000&amp;hl=zh-CN&amp;gl=cn&amp;x=&#123;$x&#125;&amp;y=&#123;$y&#125;&amp;z=&#123;$z&#125;&amp;s=Galileo</code></td><td>只有路网，256px</td></tr><tr><td><strong>路网大字体</strong></td><td><code>/vt/imgtp=png32&amp;lyrs=h@292000000&amp;hl=zh-CN&amp;gl=cn&amp;x=&#123;$x/2&#125;&amp;y=&#123;$y/2&#125;&amp;z=&#123;$z-1&#125;&amp;scale=2&amp;s=Galileo</code></td><td>只有路网，512px</td></tr></tbody></table><blockquote><p><strong>注意</strong>：最常用的是 <strong>卫星影像图</strong>，如果想要路网叠加效果，可以单独再添加一个路网图层叠加上去。</p></blockquote><h3 id="4-测试加载"><a href="#4-测试加载" class="headerlink" title="4. 测试加载"></a>4. 测试加载</h3><p>添加完之后，回到主界面，在地图切换里找到咱们刚加的 “Google卫星图（反代）”，切换过去看看能不能正常显示。</p><h3 id="5-叠加路网（可选）"><a href="#5-叠加路网（可选）" class="headerlink" title="5. 叠加路网（可选）"></a>5. 叠加路网（可选）</h3><p>如果觉得纯卫星图不方便认路，可以再添加一个路网图层：</p><ol><li>再次点击 <strong>添加</strong>，新建一个自定义地图</li><li>地图名称填 <strong>Google路网</strong></li><li>URL 模板选择上表的 <strong>路网小字体</strong></li><li>配置好后，在奥维里可以同时显示卫星图+路网，或者切换叠加模式</li></ol><h3 id="6-如何验证反代是否正常工作？"><a href="#6-如何验证反代是否正常工作？" class="headerlink" title="6. 如何验证反代是否正常工作？"></a>6. 如何验证反代是否正常工作？</h3><p>在浏览器里访问以下地址测试（把域名换成你自己的）：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">https://map.yourdomain.com/vt/lyrs=s@699&amp;hl=zh-CN&amp;gl=cn&amp;src=app&amp;x=1&amp;y=1&amp;z=1</span><br></pre></td></tr></table></figure><p>如果返回图片，说明反代工作正常。</p><h2 id="五、搞定！"><a href="#五、搞定！" class="headerlink" title="五、搞定！"></a>五、搞定！</h2><p>通过 Cloudflare Workers 反向代理这个免费方案，咱们终于能在国内愉快地看 Google 高清卫星图了！</p>]]>
    </content>
    <id>https://passage.kaze.zone/posts/google-satellite-map-with-ovitalMap/</id>
    <link href="https://passage.kaze.zone/posts/google-satellite-map-with-ovitalMap/"/>
    <published>2026-04-28T09:05:00.000Z</published>
    <summary>
      <![CDATA[<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>有没有发现咱们国内的卫星地图放大到一定程度就”糊”了？想看看自家位置？不好意思，看不清… </p>
<p>别慌：用 Cloudflare W]]>
    </summary>
    <title>
      <![CDATA[境内卫图糊到爆？用奥维 & 反代 Google 卫星图替代！]]>
    </title>
    <updated>2026-04-30T04:40:28.570Z</updated>
  </entry>
  <entry>
    <author>
      <name>卡泽</name>
    </author>
    <category term="折腾记录" scheme="https://passage.kaze.zone/categories/%E6%8A%98%E8%85%BE%E8%AE%B0%E5%BD%95/"/>
    <category term="Microsoft 365" scheme="https://passage.kaze.zone/tags/Microsoft-365/"/>
    <category term="SharePoint" scheme="https://passage.kaze.zone/tags/SharePoint/"/>
    <content>
      <![CDATA[<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>注册 Microsoft 365 的时候，系统会自动给你分配一个 <code>*.onmicrosoft.com</code> 的域名。SharePoint 和 OneDrive 默认就会用这个丑地址。</p><p>想换个好看点的 onmicrosoft.com 前缀？今天来教你怎么搞！</p><h2 id="一、前期准备"><a href="#一、前期准备" class="headerlink" title="一、前期准备"></a>一、前期准备</h2><h3 id="1-1-检查新域名有没有被占"><a href="#1-1-检查新域名有没有被占" class="headerlink" title="1.1 检查新域名有没有被占"></a>1.1 检查新域名有没有被占</h3><p>先在浏览器里打开：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">https://你的新域名.sharepoint.com</span><br></pre></td></tr></table></figure><p>看看返回啥：</p><ul><li>报 404 或找不到页面 → 这个域名<strong>能用</strong></li><li>要你登录或显示用户信息 → 域名<strong>已经被占了</strong>，换一个试试</li></ul><h3 id="1-2-添加新的-onmicrosoft-com-域名"><a href="#1-2-添加新的-onmicrosoft-com-域名" class="headerlink" title="1.2 添加新的 onmicrosoft.com 域名"></a>1.2 添加新的 onmicrosoft.com 域名</h3><p>打开这个链接：<a href="https://aka.ms/SPORenameAddDomain">https://aka.ms/SPORenameAddDomain</a></p><p>操作步骤：</p><ol><li>用 <strong>浏览器</strong> 打开</li><li>用 Microsoft 365 <strong>全局管理员</strong>账号登录</li><li>点 <strong>Add Custom Domain</strong> 或 <strong>添加自定义域</strong></li><li>输入新的域名前缀，比如 <code>newname</code></li><li>确认添加</li></ol><p>注意事项：</p><ul><li>加了之后<strong>删不掉</strong></li><li>每个账户最多只能加 <strong>30 个</strong> onmicrosoft 域名</li></ul><h2 id="二、执行重命名"><a href="#二、执行重命名" class="headerlink" title="二、执行重命名"></a>二、执行重命名</h2><h3 id="2-1-安装-PowerShell-工具"><a href="#2-1-安装-PowerShell-工具" class="headerlink" title="2.1 安装 PowerShell 工具"></a>2.1 安装 PowerShell 工具</h3><p>下载 SharePoint Online Management Shell：</p><a class="btn-beautify " href="https://go.microsoft.com/fwlink/p/?LinkId=255251" title="下载 SharePoint Online Management Shell"><i class="download"></i><span>下载 SharePoint Online Management Shell</span></a><p>装好之后在开始菜单找 <strong>SharePoint Online Management Shell</strong> 打开。</p><h3 id="2-2-连接到-SharePoint-管理中心"><a href="#2-2-连接到-SharePoint-管理中心" class="headerlink" title="2.2 连接到 SharePoint 管理中心"></a>2.2 连接到 SharePoint 管理中心</h3><p>先看看你的管理域名是啥：打开 OneDrive，看地址栏格式是 <code>https://你的前缀-my.sharepoint.com/personal/...</code>，其中 <code>你的前缀</code> 就是当前域名。</p><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 连接到 SharePoint 管理中心</span></span><br><span class="line"><span class="built_in">Connect-SPOService</span> <span class="literal">-Url</span> <span class="string">&quot;https://你的前缀-admin.sharepoint.com&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 比如</span></span><br><span class="line"><span class="built_in">Connect-SPOService</span> <span class="literal">-Url</span> <span class="string">&quot;https://username-admin.sharepoint.com&quot;</span></span><br></pre></td></tr></table></figure><p>执行后会弹登录框，用管理员账号登录。</p><h3 id="2-3-开始重命名"><a href="#2-3-开始重命名" class="headerlink" title="2.3 开始重命名"></a>2.3 开始重命名</h3><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 执行重命名计划</span></span><br><span class="line"><span class="built_in">Start-SPOTenantRename</span> <span class="literal">-DomainName</span> <span class="string">&quot;新前缀&quot;</span> <span class="literal">-ScheduledDateTime</span> <span class="string">&quot;2026-05-01T10:00:00&quot;</span></span><br></pre></td></tr></table></figure><p>参数说明：</p><table><thead><tr><th>参数</th><th>干嘛的</th><th>示例</th></tr></thead><tbody><tr><td><code>-DomainName</code></td><td>新域名前缀（不用写 .onmicrosoft.com）</td><td><code>contoso</code></td></tr><tr><td><code>-ScheduledDateTime</code></td><td>生效时间（格式：年-月-日T时:分:秒）</td><td><code>2026-05-01T10:00:00</code></td></tr></tbody></table><p>时间要求：</p><ul><li>必须比现在<strong>晚 24 小时以上</strong></li><li>最多可以预约 <strong>30 天</strong>之后</li><li>时区和电脑系统时间要一致</li></ul><p>执行后会提示确认，输入 <code>Y</code> 确认。</p><h2 id="三、查看进度"><a href="#三、查看进度" class="headerlink" title="三、查看进度"></a>三、查看进度</h2><h3 id="3-1-查询整体状态"><a href="#3-1-查询整体状态" class="headerlink" title="3.1 查询整体状态"></a>3.1 查询整体状态</h3><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 查看整体重命名状态</span></span><br><span class="line"><span class="built_in">Get-SPOTenantRenameStatus</span></span><br></pre></td></tr></table></figure><p>状态说明：</p><table><thead><tr><th>状态</th><th>啥意思</th></tr></thead><tbody><tr><td><code>Queued</code></td><td>排队呢，还没到你</td></tr><tr><td><code>InProgress</code></td><td>正在处理</td></tr><tr><td><code>Success</code></td><td>大功告成！</td></tr></tbody></table><h3 id="3-2-查看单个站点进度"><a href="#3-2-查看单个站点进度" class="headerlink" title="3.2 查看单个站点进度"></a>3.2 查看单个站点进度</h3><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 查看单个站点重命名状态</span></span><br><span class="line"><span class="built_in">Get-SPOSiteRenameState</span> <span class="literal">-ParentOperationId</span> &lt;RenameJobID&gt;</span><br></pre></td></tr></table></figure><h3 id="3-3-取消重命名"><a href="#3-3-取消重命名" class="headerlink" title="3.3 取消重命名"></a>3.3 取消重命名</h3><p>如果还没执行，可以反悔：</p><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 取消重命名（必须在计划时间之前执行）</span></span><br><span class="line"><span class="built_in">Stop-SPOTenantRename</span></span><br></pre></td></tr></table></figure><h2 id="四、验证一下"><a href="#四、验证一下" class="headerlink" title="四、验证一下"></a>四、验证一下</h2><ol><li>登录 <a href="https://admin.microsoft.com/">Microsoft 365 管理中心</a></li><li>左边菜单点 <strong>显示所有</strong> → <strong>SharePoint</strong></li><li>看看地址栏是不是变成新域名了</li></ol><h2 id="五、常见问题"><a href="#五、常见问题" class="headerlink" title="五、常见问题"></a>五、常见问题</h2><p><strong>问：报错 <code>-722</code> 是啥情况？</strong></p><p>答：计划的重命名时间离现在不足 24 小时，重新设一个更晚的时间就行。</p><p><strong>问：可以改回原来的域名吗？</strong></p><p>答：不行，微软只允许重命名一次，不支持回退。想清楚再动！</p><p><strong>问：重命名过程中会影响使用吗？</strong></p><p>答：会有一些影响。重命名期间暂时不能创建新的 OneDrive 和网站（比如 Teams 新团队）。</p><h2 id="搞定收工！"><a href="#搞定收工！" class="headerlink" title="搞定收工！"></a>搞定收工！</h2><p>SharePoint 和 OneDrive 的 URL 都变成你想要的样子了，看着舒服多了！</p><h2 id="参考链接"><a href="#参考链接" class="headerlink" title="参考链接"></a>参考链接</h2><ul><li><a href="https://learn.microsoft.com/zh-cn/sharepoint/change-your-sharepoint-domain-name">Microsoft 官方文档：重命名 SharePoint 域</a></li></ul>]]>
    </content>
    <id>https://passage.kaze.zone/posts/microsoft-365-change-fallback-domain/</id>
    <link href="https://passage.kaze.zone/posts/microsoft-365-change-fallback-domain/"/>
    <published>2026-04-27T09:19:00.000Z</published>
    <summary>
      <![CDATA[<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>注册 Microsoft 365 的时候，系统会自动给你分配一个 <code>*.onmicrosoft.com</code> 的域名。Sh]]>
    </summary>
    <title>Microsoft 365 更改 SharePoint 域名</title>
    <updated>2026-04-30T04:40:28.582Z</updated>
  </entry>
  <entry>
    <author>
      <name>卡泽</name>
    </author>
    <category term="折腾记录" scheme="https://passage.kaze.zone/categories/%E6%8A%98%E8%85%BE%E8%AE%B0%E5%BD%95/"/>
    <category term="Cloudflare" scheme="https://passage.kaze.zone/tags/Cloudflare/"/>
    <category term="TLS" scheme="https://passage.kaze.zone/tags/TLS/"/>
    <content>
      <![CDATA[<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>话说用 Cloudflare 的免费版有个好处，就是证书不用自己操心，它自动给你安排得明明白白。</p><p>不过呢，免费计划里其实有三种证书可选：Let’s Encrypt、Google Trust Services、还有 SSL.com。它们都是三个月有效期的。</p><p>默认情况下 Cloudflare 会自动挑 Let’s Encrypt 或 Google Trust Services 用。但如果哪天你想换个口味，比如用 SSL.com，那就得自己动手改一改了——因为控制台没给这个选项，得用 API 来搞。</p><blockquote><p><strong>2025年3月更新</strong>：DigiCert 一年期证书已经没了，现在新增了 SSL.com 三个月期证书。</p></blockquote><h2 id="一、先把家伙准备好"><a href="#一、先把家伙准备好" class="headerlink" title="一、先把家伙准备好"></a>一、先把家伙准备好</h2><p>搞之前得备齐三样东西：<strong>Zone ID</strong>、<strong>邮箱</strong> 和 <strong>Global API Key</strong>。没这些，后面玩不转。</p><h3 id="1-Zone-ID-在哪找？"><a href="#1-Zone-ID-在哪找？" class="headerlink" title="1. Zone ID 在哪找？"></a>1. Zone ID 在哪找？</h3><ol><li>登录 <a href="https://dash.cloudflare.com/">Cloudflare Dashboard</a></li><li>选中有问题的那个域名，点进去</li><li>左边菜单找 <strong>概述</strong></li><li>页面右下角有个 <strong>API</strong> 区域，<strong>区域 ID</strong> 就在那儿，复制一下</li></ol><h3 id="2-Global-API-Key-怎么拿？"><a href="#2-Global-API-Key-怎么拿？" class="headerlink" title="2. Global API Key 怎么拿？"></a>2. Global API Key 怎么拿？</h3><ol><li>点右上角那个小人头 → <strong>我的个人资料</strong></li><li>左边菜单选 <strong>API 令牌</strong></li><li>找到 <strong>API 密钥</strong> 这一栏</li><li>点 <strong>Global API Key</strong> 后面的 <strong>查看</strong></li><li>会让你验证邮箱，验证完复制 Key 就行</li></ol><blockquote><p><strong>友情提醒</strong>：API Key 就相当于你的账号密码，可别随手发给别人！</p></blockquote><h2 id="二、开搞！敲命令换证书"><a href="#二、开搞！敲命令换证书" class="headerlink" title="二、开搞！敲命令换证书"></a>二、开搞！敲命令换证书</h2><p>打开终端，把下面这坨命令复制进去，记得把占位符换成你自己的信息：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">curl -X PATCH <span class="string">&quot;https://api.cloudflare.com/client/v4/zones/你的Zone_ID/ssl/universal/settings&quot;</span> \</span><br><span class="line">     -H <span class="string">&quot;X-Auth-Email: 你的Cloudflare邮箱&quot;</span> \</span><br><span class="line">     -H <span class="string">&quot;X-Auth-Key: 你的Global_API_Key&quot;</span> \</span><br><span class="line">     -H <span class="string">&quot;Content-Type: application/json&quot;</span> \</span><br><span class="line">     --data <span class="string">&#x27;&#123;&quot;certificate_authority&quot;:&quot;证书类型&quot;&#125;&#x27;</span></span><br></pre></td></tr></table></figure><h3 id="证书类型参数对照表"><a href="#证书类型参数对照表" class="headerlink" title="证书类型参数对照表"></a>证书类型参数对照表</h3><table><thead><tr><th>想用哪个</th><th>参数填啥</th></tr></thead><tbody><tr><td>Let’s Encrypt</td><td><code>lets_encrypt</code></td></tr><tr><td>Google Trust Services</td><td><code>google</code></td></tr><tr><td>SSL.com</td><td><code>ssl_com</code></td></tr></tbody></table><p>拿 Let’s Encrypt 举例：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">curl -X PATCH <span class="string">&quot;https://api.cloudflare.com/client/v4/zones/你的Zone_ID/ssl/universal/settings&quot;</span> \</span><br><span class="line">     -H <span class="string">&quot;X-Auth-Email: 你的Cloudflare邮箱&quot;</span> \</span><br><span class="line">     -H <span class="string">&quot;X-Auth-Key: 你的Global_API_Key&quot;</span> \</span><br><span class="line">     -H <span class="string">&quot;Content-Type: application/json&quot;</span> \</span><br><span class="line">     --data <span class="string">&#x27;&#123;&quot;certificate_authority&quot;:&quot;lets_encrypt&quot;&#125;&#x27;</span></span><br></pre></td></tr></table></figure><h2 id="三、看看改成功没"><a href="#三、看看改成功没" class="headerlink" title="三、看看改成功没"></a>三、看看改成功没</h2><p>执行完如果顺利，返回的 JSON 里 <code>success</code> 应该是 <code>true</code>：</p><figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">  <span class="attr">&quot;result&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;enabled&quot;</span><span class="punctuation">:</span> <span class="literal"><span class="keyword">true</span></span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;certificate_authority&quot;</span><span class="punctuation">:</span> <span class="string">&quot;lets_encrypt&quot;</span></span><br><span class="line">  <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;success&quot;</span><span class="punctuation">:</span> <span class="literal"><span class="keyword">true</span></span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;errors&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span><span class="punctuation">]</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;messages&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span><span class="punctuation">]</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br></pre></td></tr></table></figure><p>要是 <code>success</code> 变成 <code>false</code> 了，先检查一下命令里的参数填对了没有。</p><h3 id="命令行快速验货"><a href="#命令行快速验货" class="headerlink" title="命令行快速验货"></a>命令行快速验货</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">curl -Iv https://你的域名.com 2&gt;&amp;1 | grep <span class="string">&quot;issuer&quot;</span></span><br></pre></td></tr></table></figure><p>这个能直接看到现在用的是哪个证书。</p><h2 id="四、万一证书没更新怎么办"><a href="#四、万一证书没更新怎么办" class="headerlink" title="四、万一证书没更新怎么办"></a>四、万一证书没更新怎么办</h2><p>有时候改完网页显示的还是旧证书，别慌，强制刷新一下：</p><ol><li>进 Cloudflare 控制台</li><li>找到 <strong>SSL&#x2F;TLS</strong> → <strong>边缘证书</strong></li><li>先把 <strong>通用 SSL</strong> 关掉，等个几秒</li><li>再重新开启</li><li>清除浏览器缓存，打开网站看看</li></ol><h2 id="搞定收工！"><a href="#搞定收工！" class="headerlink" title="搞定收工！"></a>搞定收工！</h2><p>证书换成你想要的了，接下来就不用操心了，Cloudflare 会自动续期的。</p>]]>
    </content>
    <id>https://passage.kaze.zone/posts/cloudflare-api-change-ssl-certificate/</id>
    <link href="https://passage.kaze.zone/posts/cloudflare-api-change-ssl-certificate/"/>
    <published>2026-04-20T08:43:00.000Z</published>
    <summary>
      <![CDATA[<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>话说用 Cloudflare 的免费版有个好处，就是证书不用自己操心，它自动给你安排得明明白白。</p>
<p>不过呢，免费计划里其实有三种]]>
    </summary>
    <title>通过 API 更换 Cloudflare SSL 证书类型</title>
    <updated>2026-04-30T04:40:28.558Z</updated>
  </entry>
  <entry>
    <author>
      <name>卡泽</name>
    </author>
    <category term="折腾记录" scheme="https://passage.kaze.zone/categories/%E6%8A%98%E8%85%BE%E8%AE%B0%E5%BD%95/"/>
    <category term="Cloudflare" scheme="https://passage.kaze.zone/tags/Cloudflare/"/>
    <category term="IPv6" scheme="https://passage.kaze.zone/tags/IPv6/"/>
    <content>
      <![CDATA[<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>想关闭 Cloudflare 的 IPv6？去控制面板翻了一圈，发现只有”开启”的选项，没有”关闭”。</p><p>别慌，官方其实是支持关闭的，只是藏在 API 里。今天来把它挖出来。</p><h2 id="一、先把家伙准备好"><a href="#一、先把家伙准备好" class="headerlink" title="一、先把家伙准备好"></a>一、先把家伙准备好</h2><p>搞之前得备齐三样东西：<strong>Zone ID</strong>、<strong>邮箱</strong> 和 <strong>Global API Key</strong>。</p><h3 id="1-Zone-ID-在哪找？"><a href="#1-Zone-ID-在哪找？" class="headerlink" title="1. Zone ID 在哪找？"></a>1. Zone ID 在哪找？</h3><ol><li>登录 <a href="https://dash.cloudflare.com/">Cloudflare Dashboard</a></li><li>选中有问题的那个域名，点进去</li><li>左边菜单找 <strong>概述</strong></li><li>页面右下角有个 <strong>API</strong> 区域，<strong>区域 ID</strong> 就在那儿，复制一下</li></ol><h3 id="2-Global-API-Key-怎么拿？"><a href="#2-Global-API-Key-怎么拿？" class="headerlink" title="2. Global API Key 怎么拿？"></a>2. Global API Key 怎么拿？</h3><ol><li>点右上角小人头 → <strong>我的个人资料</strong></li><li>左边菜单选 <strong>API 令牌</strong></li><li>找到 <strong>API 密钥</strong> 这一栏</li><li>点 <strong>Global API Key</strong> 后面的 <strong>查看</strong></li><li>会让你验证邮箱，验证完复制 Key 就行</li></ol><h2 id="二、关闭-IPv6"><a href="#二、关闭-IPv6" class="headerlink" title="二、关闭 IPv6"></a>二、关闭 IPv6</h2><p>把下面这坨命令复制进终端，记得把占位符换成你自己的：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">curl -X PATCH <span class="string">&quot;https://api.cloudflare.com/client/v4/zones/你的Zone_ID/settings/ipv6&quot;</span> \</span><br><span class="line">     -H <span class="string">&quot;X-Auth-Email: 你的Cloudflare邮箱&quot;</span> \</span><br><span class="line">     -H <span class="string">&quot;X-Auth-Key: 你的Global_API_Key&quot;</span> \</span><br><span class="line">     -H <span class="string">&quot;Content-Type: application/json&quot;</span> \</span><br><span class="line">     --data <span class="string">&#x27;&#123;&quot;value&quot;:&quot;off&quot;&#125;&#x27;</span></span><br></pre></td></tr></table></figure><h2 id="三、想重新开启？也行"><a href="#三、想重新开启？也行" class="headerlink" title="三、想重新开启？也行"></a>三、想重新开启？也行</h2><p>以后如果又想开回去，把命令里的 <code>&quot;off&quot;</code> 改成 <code>&quot;on&quot;</code> 就好：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">curl -X PATCH <span class="string">&quot;https://api.cloudflare.com/client/v4/zones/你的Zone_ID/settings/ipv6&quot;</span> \</span><br><span class="line">     -H <span class="string">&quot;X-Auth-Email: 你的Cloudflare邮箱&quot;</span> \</span><br><span class="line">     -H <span class="string">&quot;X-Auth-Key: 你的Global_API_Key&quot;</span> \</span><br><span class="line">     -H <span class="string">&quot;Content-Type: application/json&quot;</span> \</span><br><span class="line">     --data <span class="string">&#x27;&#123;&quot;value&quot;:&quot;on&quot;&#125;&#x27;</span></span><br></pre></td></tr></table></figure><h2 id="四、看看改成功没"><a href="#四、看看改成功没" class="headerlink" title="四、看看改成功没"></a>四、看看改成功没</h2><p>执行完如果顺利，返回的 JSON 里 <code>success</code> 应该是 <code>true</code>：</p><figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">  <span class="attr">&quot;result&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;id&quot;</span><span class="punctuation">:</span> <span class="string">&quot;ipv6&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;value&quot;</span><span class="punctuation">:</span> <span class="string">&quot;off&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;modified_on&quot;</span><span class="punctuation">:</span> <span class="string">&quot;2026-04-27T17:10:00.000000Z&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;editable&quot;</span><span class="punctuation">:</span> <span class="literal"><span class="keyword">true</span></span></span><br><span class="line">  <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;success&quot;</span><span class="punctuation">:</span> <span class="literal"><span class="keyword">true</span></span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;errors&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span><span class="punctuation">]</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;messages&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span><span class="punctuation">]</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br></pre></td></tr></table></figure><p>看 <code>result.value</code> 是 <code>off</code> 就说明成功了。</p><h2 id="五、查询当前状态"><a href="#五、查询当前状态" class="headerlink" title="五、查询当前状态"></a>五、查询当前状态</h2><p>想知道现在 IPv6 是开还是关？执行这个命令：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">curl -X GET <span class="string">&quot;https://api.cloudflare.com/client/v4/zones/你的Zone_ID/settings/ipv6&quot;</span> \</span><br><span class="line">     -H <span class="string">&quot;X-Auth-Email: 你的Cloudflare邮箱&quot;</span> \</span><br><span class="line">     -H <span class="string">&quot;X-Auth-Key: 你的Global_API_Key&quot;</span></span><br></pre></td></tr></table></figure><p>返回的 <code>result.value</code> 会告诉你答案：<code>&quot;on&quot;</code> 就是开着的，<code>&quot;off&quot;</code> 就是关着的。</p>]]>
    </content>
    <id>https://passage.kaze.zone/posts/cloudflare-api-disable-ipv6/</id>
    <link href="https://passage.kaze.zone/posts/cloudflare-api-disable-ipv6/"/>
    <published>2026-04-10T09:10:00.000Z</published>
    <summary>
      <![CDATA[<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>想关闭 Cloudflare 的 IPv6？去控制面板翻了一圈，发现只有”开启”的选项，没有”关闭”。</p>
<p>别慌，官方其实是支持关]]>
    </summary>
    <title>通过 API 禁用 Cloudflare IPv6</title>
    <updated>2026-04-30T04:40:28.562Z</updated>
  </entry>
  <entry>
    <author>
      <name>卡泽</name>
    </author>
    <category term="折腾记录" scheme="https://passage.kaze.zone/categories/%E6%8A%98%E8%85%BE%E8%AE%B0%E5%BD%95/"/>
    <category term="Hexo" scheme="https://passage.kaze.zone/tags/Hexo/"/>
    <content>
      <![CDATA[<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>Hexo 写完文章总得发到网上让人看吧？最简单的方法就是部署到 GitHub Pages，而且还免费！</p><p>今天把这个配置过程理一理，省得每次都要翻文档。</p><h2 id="一、先装部署插件"><a href="#一、先装部署插件" class="headerlink" title="一、先装部署插件"></a>一、先装部署插件</h2><p>Hexo 默认不带 Git 部署功能，得自己装一个：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install hexo-deployer-git --save</span><br></pre></td></tr></table></figure><p>就一行命令，搞定。</p><h2 id="二、配置-Git-用户信息"><a href="#二、配置-Git-用户信息" class="headerlink" title="二、配置 Git 用户信息"></a>二、配置 Git 用户信息</h2><p>告诉 Git 你是谁，以后提交记录会显示这个名字：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git config --global user.name <span class="string">&quot;你的GitHub用户名&quot;</span></span><br><span class="line">git config --global user.email <span class="string">&quot;你的GitHub关联邮箱&quot;</span></span><br></pre></td></tr></table></figure><blockquote><p>邮箱最好填 GitHub 账号绑定的那个，不然 GitHub 上的小绿点贡献记录会对不上号。</p></blockquote><h2 id="三、生成-SSH-密钥"><a href="#三、生成-SSH-密钥" class="headerlink" title="三、生成 SSH 密钥"></a>三、生成 SSH 密钥</h2><p>这一步是为了让服务器认识你的电脑，不用每次部署都输入密码：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh-keygen -t rsa -C <span class="string">&quot;你的GitHub关联邮箱&quot;</span></span><br></pre></td></tr></table></figure><p>一路回车就行，啥都不用改。生成完之后去 <code>~/.ssh/id_rsa.pub</code> 文件，把里面的内容复制出来。</p><h2 id="四、把公钥加到-GitHub"><a href="#四、把公钥加到-GitHub" class="headerlink" title="四、把公钥加到 GitHub"></a>四、把公钥加到 GitHub</h2><ol><li>登录 GitHub，点右上角头像 → <strong>Settings</strong></li><li>左边菜单找 <strong>SSH and GPG keys</strong></li><li>点 <strong>New SSH key</strong></li><li>标题随便起（比如”我的电脑”），把刚才复制的公钥内容粘贴进去</li><li>点保存</li></ol><h2 id="五、验证-SSH-连上了没"><a href="#五、验证-SSH-连上了没" class="headerlink" title="五、验证 SSH 连上了没"></a>五、验证 SSH 连上了没</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh -T git@github.com</span><br></pre></td></tr></table></figure><p>如果看到 <code>Hi xxx! You&#39;ve successfully authenticated...</code>，说明配置成功了，可以直接连 GitHub。</p><h2 id="六、配置-Hexo-部署"><a href="#六、配置-Hexo-部署" class="headerlink" title="六、配置 Hexo 部署"></a>六、配置 Hexo 部署</h2><p>打开项目根目录下的 <code>_config.yml</code>，找到 <code>deploy</code> 部分，改成这样：</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">deploy:</span></span><br><span class="line">  <span class="attr">type:</span> <span class="string">git</span></span><br><span class="line">  <span class="attr">repo:</span> <span class="string">git@github.com:你的GitHub用户名/你的GitHub用户名.github.io.git</span></span><br><span class="line">  <span class="attr">branch:</span> <span class="string">main</span></span><br></pre></td></tr></table></figure><p>记得把 <code>你的GitHub用户名</code> 换成你自己的。</p><h2 id="搞定收工！"><a href="#搞定收工！" class="headerlink" title="搞定收工！"></a>搞定收工！</h2><p>配置好之后，以后每次部署只需要：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo clean &amp;&amp; hexo deploy</span><br></pre></td></tr></table></figure><p>Hexo 会自动帮你清理、生成、上传，一条龙服务。</p>]]>
    </content>
    <id>https://passage.kaze.zone/posts/hexo-configure-git-repository/</id>
    <link href="https://passage.kaze.zone/posts/hexo-configure-git-repository/"/>
    <published>2026-04-08T08:23:35.000Z</published>
    <summary>
      <![CDATA[<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>Hexo 写完文章总得发到网上让人看吧？最简单的方法就是部署到 GitHub Pages，而且还免费！</p>
<p>今天把这个配置过程理一]]>
    </summary>
    <title>Hexo 配置 Git 部署到 GitHub Pages</title>
    <updated>2026-04-30T04:40:28.578Z</updated>
  </entry>
  <entry>
    <author>
      <name>卡泽</name>
    </author>
    <category term="折腾记录" scheme="https://passage.kaze.zone/categories/%E6%8A%98%E8%85%BE%E8%AE%B0%E5%BD%95/"/>
    <category term="Debian" scheme="https://passage.kaze.zone/tags/Debian/"/>
    <content>
      <![CDATA[<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>说起来有点尴尬，最近在服务器上部署 Docker，选了 Debian 10 当系统。结果装完之后想更新一下软件，啪，软件源用不了了——</p><p>一查才发现，原来 Debian 10 在 2024 年 6 月就停止维护了，官方源早就撤了。</p><p>不过别急着重装系统，换个归档源就能继续用。今天把这个过程记下来，省得下次又踩坑。</p><blockquote><p><strong>注意</strong>：Debian 10 已经彻底没人维护了，安全更新啥的都没有了。如果不是必须用，建议还是换个还在活跃维护的版本吧。</p></blockquote><h2 id="开始搞"><a href="#开始搞" class="headerlink" title="开始搞"></a>开始搞</h2><h3 id="第一步：先备份，养成好习惯"><a href="#第一步：先备份，养成好习惯" class="headerlink" title="第一步：先备份，养成好习惯"></a>第一步：先备份，养成好习惯</h3><p>不管干啥，先备份总没错。执行：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cp</span> /etc/apt/sources.list /etc/apt/sources.list.bak</span><br></pre></td></tr></table></figure><p>这样就算改坏了，一行命令就能还原。</p><h3 id="第二步：打开源列表文件"><a href="#第二步：打开源列表文件" class="headerlink" title="第二步：打开源列表文件"></a>第二步：打开源列表文件</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">nano /etc/apt/sources.list</span><br></pre></td></tr></table></figure><p>nano 是个简单好用的编辑器，直接在终端里改文件。</p><h3 id="第三步：全部删掉，换成归档源"><a href="#第三步：全部删掉，换成归档源" class="headerlink" title="第三步：全部删掉，换成归档源"></a>第三步：全部删掉，换成归档源</h3><p>把里面的东西全部删掉（或者直接全选覆盖），换成下面这些：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">deb http://archive.debian.org/debian/ buster main contrib non-free</span><br><span class="line">deb http://archive.debian.org/debian/ buster-updates main contrib non-free</span><br><span class="line">deb http://archive.debian.org/debian-security buster/updates main contrib non-free</span><br></pre></td></tr></table></figure><p>保存退出：按 <code>Ctrl + O</code> 保存，回车确认，然后 <code>Ctrl + X</code> 退出 nano。</p><h3 id="第四步：更新软件列表"><a href="#第四步：更新软件列表" class="headerlink" title="第四步：更新软件列表"></a>第四步：更新软件列表</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">apt update -o Acquire::Check-Valid-Until=<span class="literal">false</span></span><br></pre></td></tr></table></figure><p>加那个参数是因为归档源的文件没有 valid-until 标记，不加会报错。</p><h2 id="搞定收工！"><a href="#搞定收工！" class="headerlink" title="搞定收工！"></a>搞定收工！</h2><p>好了，现在可以正常用 apt 安装软件了。虽然是老系统，但至少能跑起来。</p><p>不过说真的，要是条件允许，还是建议升级到 Debian 11&#x2F;12，毕竟安全和稳定性更重要嘛。</p>]]>
    </content>
    <id>https://passage.kaze.zone/posts/debian-10-change-archive-sources/</id>
    <link href="https://passage.kaze.zone/posts/debian-10-change-archive-sources/"/>
    <published>2026-03-31T06:30:00.000Z</published>
    <summary>
      <![CDATA[<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>说起来有点尴尬，最近在服务器上部署 Docker，选了 Debian 10 当系统。结果装完之后想更新一下软件，啪，软件源用不了了——</p]]>
    </summary>
    <title>Debian 10 更换归档源</title>
    <updated>2026-04-30T04:40:28.566Z</updated>
  </entry>
</feed>
