<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"><channel>
<title>Onc</title>
<link>https://blog.onc.cc</link>
<description>Onc 的文章：Rust、技术与极简主义。</description>
<language>zh-CN</language>
<item>
<title>AnyTLS 部署指南（sing-box）</title>
<link>https://blog.onc.cc/post/anytls-deploy</link>
<guid isPermaLink="true">https://blog.onc.cc/post/anytls-deploy</guid>
<pubDate>Tue, 22 Sep 2026 00:00:00 GMT</pubDate>
<description>&lt;p&gt;AnyTLS 占用 &lt;strong&gt;TCP 443&lt;/strong&gt;。证书用 ACME（推荐，要域名）或自签名。ACME 使用 &lt;code&gt;certificate_providers&lt;/code&gt;，需要 sing-box &lt;strong&gt;1.14.0 及以上&lt;/strong&gt;。不要改回已废弃的 &lt;code&gt;tls.acme&lt;/code&gt;，它会在 1.16.0 移除。入站占着 443，不能用 TLS-ALPN，只用 HTTP-01（TCP 80）或 DNS-01。域名为 IP 时，Let's Encrypt 会自动使用 &lt;code&gt;shortlived&lt;/code&gt; profile，所以推荐域名。字段见 &lt;a href=&quot;https://sing-box.sagernet.org/configuration/inbound/anytls/&quot;&gt;AnyTLS inbound&lt;/a&gt;。&lt;/p&gt;
&lt;h2 id=&quot;准备&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#准备&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;准备&lt;/span&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;带 systemd 的 Linux VPS，有 root 或 &lt;code&gt;sudo&lt;/code&gt;；官方安装脚本覆盖 deb、rpm、Arch、OpenWrt。&lt;/li&gt;
&lt;li&gt;一个解析到该 VPS 的域名，以及可收信的邮箱。&lt;/li&gt;
&lt;li&gt;安全组和本机防火墙放行 TCP &lt;code&gt;443&lt;/code&gt;；HTTP-01 还要放行 TCP &lt;code&gt;80&lt;/code&gt;。443 不能被 Nginx 或 Caddy 占用。&lt;/li&gt;
&lt;li&gt;一个足够长的随机密码。&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;安装&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#安装&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;安装&lt;/span&gt;&lt;/h2&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-1&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-1&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;curl -fsSL https://sing-box.app/install.sh | sh
sing-box version&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;版本必须 ≥ 1.14.0，否则不认识 &lt;code&gt;certificate_providers&lt;/code&gt;。&lt;/p&gt;
&lt;h2 id=&quot;证书&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#证书&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;证书&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;ACME 按下一节配置，sing-box 会申请并续期。自签名则不要长期开 &lt;code&gt;insecure&lt;/code&gt;：&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-2&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-2&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;sudo openssl ecparam -name prime256v1 -genkey -noout \
  -out /etc/sing-box/server.key

sudo openssl req -x509 -nodes \
  -key /etc/sing-box/server.key \
  -out /etc/sing-box/server.crt \
  -subj &amp;quot;/CN=bing.com&amp;quot; \
  -addext &amp;quot;subjectAltName=DNS:bing.com&amp;quot; \
  -days 825

sudo chmod 600 /etc/sing-box/server.key
sudo chmod 644 /etc/sing-box/server.crt&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;&lt;code&gt;CN=bing.com&lt;/code&gt; 只是示例名。导入客户端并严格校验时，SAN 必须与 &lt;code&gt;server_name&lt;/code&gt; 一致。密钥用 P-256，不要改成 Ed25519。自签名时删掉 &lt;code&gt;certificate_providers&lt;/code&gt;，把 &lt;code&gt;tls&lt;/code&gt; 换成：&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-3&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-3&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;&amp;quot;tls&amp;quot;: {
  &amp;quot;enabled&amp;quot;: true,
  &amp;quot;certificate_path&amp;quot;: &amp;quot;/etc/sing-box/server.crt&amp;quot;,
  &amp;quot;key_path&amp;quot;: &amp;quot;/etc/sing-box/server.key&amp;quot;
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;服务端&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#服务端&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;服务端&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;写入 &lt;code&gt;/etc/sing-box/config.json&lt;/code&gt;：&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-4&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-4&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;{
  &amp;quot;log&amp;quot;: {
    &amp;quot;level&amp;quot;: &amp;quot;info&amp;quot;,
    &amp;quot;timestamp&amp;quot;: true
  },
  &amp;quot;certificate_providers&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;acme&amp;quot;,
      &amp;quot;tag&amp;quot;: &amp;quot;acme_cert&amp;quot;,
      &amp;quot;domain&amp;quot;: [
        &amp;quot;YOUR_DOMAIN&amp;quot;
      ],
      &amp;quot;email&amp;quot;: &amp;quot;YOUR_EMAIL@example.com&amp;quot;,
      &amp;quot;data_directory&amp;quot;: &amp;quot;/var/lib/sing-box/certmagic&amp;quot;
    }
  ],
  &amp;quot;inbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;anytls&amp;quot;,
      &amp;quot;listen&amp;quot;: &amp;quot;::&amp;quot;,
      &amp;quot;listen_port&amp;quot;: 443,
      &amp;quot;users&amp;quot;: [
        {
          &amp;quot;password&amp;quot;: &amp;quot;CHANGE_THIS_TO_A_STRONG_PASSWORD&amp;quot;
        }
      ],
      &amp;quot;tls&amp;quot;: {
        &amp;quot;enabled&amp;quot;: true,
        &amp;quot;server_name&amp;quot;: &amp;quot;YOUR_DOMAIN&amp;quot;,
        &amp;quot;certificate_provider&amp;quot;: &amp;quot;acme_cert&amp;quot;
      }
    }
  ],
  &amp;quot;outbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;direct&amp;quot;
    }
  ]
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;&lt;code&gt;data_directory&lt;/code&gt; 必须在官方服务的 &lt;code&gt;StateDirectory&lt;/code&gt;（&lt;code&gt;/var/lib/sing-box&lt;/code&gt;）下。省略时数据跟着 &lt;code&gt;sing-box&lt;/code&gt; 用户的 &lt;code&gt;HOME&lt;/code&gt; 走，重启后可能写不进去。&lt;code&gt;YOUR_DOMAIN&lt;/code&gt; 在 &lt;code&gt;domain[0]&lt;/code&gt; 和 &lt;code&gt;tls.server_name&lt;/code&gt; 两处必须一致，并且已经解析到这台 VPS。&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;&lt;tr&gt;
&lt;th&gt;配置项&lt;/th&gt;
&lt;th&gt;修改为&lt;/th&gt;
&lt;/tr&gt;&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;certificate_providers[0].domain[0]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;解析到该 VPS 的域名&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;certificate_providers[0].email&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;邮箱&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;users[0].password&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;长随机密码&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;tls.server_name&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;与证书域名相同&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;listen&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;禁用 IPv6 时改为 &lt;code&gt;0.0.0.0&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;code&gt;padding_scheme&lt;/code&gt; 留空即用内置默认值，客户端不用配。&lt;code&gt;users[].name&lt;/code&gt; 只用于日志。不要设置 &lt;code&gt;client_metadata&lt;/code&gt;：1.13.16 起默认留空，加回去没有协议用途。&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-5&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-5&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;sudo chmod 600 /etc/sing-box/config.json
sudo sing-box check -c /etc/sing-box/config.json
sudo systemctl enable sing-box
sudo systemctl restart sing-box&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;日志：&lt;code&gt;sudo journalctl -u sing-box -e&lt;/code&gt;。&lt;/p&gt;
&lt;h2 id=&quot;客户端&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#客户端&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;客户端&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;本机代理是 &lt;code&gt;127.0.0.1:1080&lt;/code&gt;。ACME 证书不要加 &lt;code&gt;insecure&lt;/code&gt;。自签名应导入证书，而不是打开 &lt;code&gt;insecure&lt;/code&gt;。&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-6&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-6&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;{
  &amp;quot;log&amp;quot;: {
    &amp;quot;level&amp;quot;: &amp;quot;info&amp;quot;,
    &amp;quot;timestamp&amp;quot;: true
  },
  &amp;quot;inbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;mixed&amp;quot;,
      &amp;quot;listen&amp;quot;: &amp;quot;127.0.0.1&amp;quot;,
      &amp;quot;listen_port&amp;quot;: 1080
    }
  ],
  &amp;quot;outbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;anytls&amp;quot;,
      &amp;quot;tag&amp;quot;: &amp;quot;anytls-out&amp;quot;,
      &amp;quot;server&amp;quot;: &amp;quot;YOUR_SERVER_IP&amp;quot;,
      &amp;quot;server_port&amp;quot;: 443,
      &amp;quot;password&amp;quot;: &amp;quot;CHANGE_THIS_TO_A_STRONG_PASSWORD&amp;quot;,
      &amp;quot;tls&amp;quot;: {
        &amp;quot;enabled&amp;quot;: true,
        &amp;quot;server_name&amp;quot;: &amp;quot;YOUR_DOMAIN&amp;quot;
      }
    }
  ]
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;排查&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#排查&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;排查&lt;/span&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;443 被占用时看 &lt;code&gt;sudo ss -lntp | grep ':443'&lt;/code&gt;，停掉冲突服务或改 &lt;code&gt;listen_port&lt;/code&gt;。禁用 IPv6 时不要听 &lt;code&gt;::&lt;/code&gt;。&lt;/li&gt;
&lt;li&gt;ACME 失败时核对解析、&lt;code&gt;domain[0]&lt;/code&gt; 与 &lt;code&gt;server_name&lt;/code&gt;、TCP 80，以及 &lt;code&gt;data_directory&lt;/code&gt; 是否为 &lt;code&gt;/var/lib/sing-box/certmagic&lt;/code&gt;。不要用 TLS-ALPN。&lt;/li&gt;
&lt;li&gt;客户端密码与 &lt;code&gt;users[0].password&lt;/code&gt; 一致，安全组放行 TCP 443。日志里不应有认证失败或证书错误。&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;安全&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#安全&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;安全&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;密码用长随机值。&lt;code&gt;config.json&lt;/code&gt; 和 &lt;code&gt;server.key&lt;/code&gt; 权限 &lt;code&gt;600&lt;/code&gt;。优先 ACME。不要自定义 &lt;code&gt;client_metadata&lt;/code&gt;。升级后重新执行 &lt;code&gt;sing-box check&lt;/code&gt;。&lt;/p&gt;
</description>
</item>
<item>
<title>Hysteria2 部署指南（sing-box）</title>
<link>https://blog.onc.cc/post/hysteria2-deploy</link>
<guid isPermaLink="true">https://blog.onc.cc/post/hysteria2-deploy</guid>
<pubDate>Tue, 22 Sep 2026 00:00:00 GMT</pubDate>
<description>&lt;p&gt;Hysteria2 基于 QUIC，服务端听 &lt;strong&gt;UDP&lt;/strong&gt;。证书用 ACME（推荐，要域名）或自签名。ACME 使用 &lt;code&gt;certificate_providers&lt;/code&gt;，&lt;code&gt;bbr_profile&lt;/code&gt; 和 &lt;code&gt;gecko&lt;/code&gt; 也需要 sing-box &lt;strong&gt;1.14.0 及以上&lt;/strong&gt;。不要改回已废弃的 &lt;code&gt;tls.acme&lt;/code&gt;，它会在 1.16.0 移除。入站是 UDP 443，TCP 443 空着，所以 HTTP-01（TCP 80）和 TLS-ALPN（TCP 443）都可以。域名为 IP 时，Let's Encrypt 会自动使用 &lt;code&gt;shortlived&lt;/code&gt; profile，所以推荐域名。字段见 &lt;a href=&quot;https://sing-box.sagernet.org/configuration/inbound/hysteria2/&quot;&gt;Hysteria2 inbound&lt;/a&gt; 与 &lt;a href=&quot;https://sing-box.sagernet.org/configuration/outbound/hysteria2/&quot;&gt;outbound&lt;/a&gt;。&lt;/p&gt;
&lt;h2 id=&quot;准备&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#准备&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;准备&lt;/span&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;带 systemd 的 Linux VPS，有 root 或 &lt;code&gt;sudo&lt;/code&gt;；官方安装脚本覆盖 deb、rpm、Arch、OpenWrt。&lt;/li&gt;
&lt;li&gt;一个解析到该 VPS 的域名，以及可收信的邮箱。&lt;/li&gt;
&lt;li&gt;安全组和本机防火墙放行 UDP &lt;code&gt;443&lt;/code&gt;。端口跳跃还要放行整个 UDP 范围，例如 &lt;code&gt;20000–40000&lt;/code&gt;。&lt;/li&gt;
&lt;li&gt;ACME 按挑战方式放行 TCP &lt;code&gt;80&lt;/code&gt; 或 TCP &lt;code&gt;443&lt;/code&gt;。&lt;/li&gt;
&lt;li&gt;一个较长的随机密码。&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;安装&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#安装&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;安装&lt;/span&gt;&lt;/h2&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-1&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-1&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;curl -fsSL https://sing-box.app/install.sh | sh
sing-box version&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;版本必须 ≥ 1.14.0。&lt;/p&gt;
&lt;h2 id=&quot;证书&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#证书&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;证书&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;ACME 按下一节配置。自签名不要把 &lt;code&gt;insecure&lt;/code&gt; 当默认，也不要用 Ed25519：1.14 客户端默认鹦鹉 Chrome QUIC，Chrome 不声明 Ed25519，握手会失败。ACME 证书不受影响。&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-2&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-2&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;sudo openssl ecparam -name prime256v1 -genkey -noout \
  -out /etc/sing-box/server.key

sudo openssl req -x509 -nodes \
  -key /etc/sing-box/server.key \
  -out /etc/sing-box/server.crt \
  -subj &amp;quot;/CN=bing.com&amp;quot; \
  -addext &amp;quot;subjectAltName=DNS:bing.com&amp;quot; \
  -days 825

sudo chmod 600 /etc/sing-box/server.key
sudo chmod 644 /etc/sing-box/server.crt&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;&lt;code&gt;CN=bing.com&lt;/code&gt; 只是示例名。导入客户端并严格校验时，SAN 必须与 &lt;code&gt;server_name&lt;/code&gt; 一致。自签名时删掉 &lt;code&gt;certificate_providers&lt;/code&gt;，把 &lt;code&gt;tls&lt;/code&gt; 换成：&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-3&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-3&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;&amp;quot;tls&amp;quot;: {
  &amp;quot;enabled&amp;quot;: true,
  &amp;quot;certificate_path&amp;quot;: &amp;quot;/etc/sing-box/server.crt&amp;quot;,
  &amp;quot;key_path&amp;quot;: &amp;quot;/etc/sing-box/server.key&amp;quot;
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;服务端&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#服务端&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;服务端&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;写入 &lt;code&gt;/etc/sing-box/config.json&lt;/code&gt;：&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-4&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-4&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;{
  &amp;quot;log&amp;quot;: {
    &amp;quot;level&amp;quot;: &amp;quot;info&amp;quot;,
    &amp;quot;timestamp&amp;quot;: true
  },
  &amp;quot;certificate_providers&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;acme&amp;quot;,
      &amp;quot;tag&amp;quot;: &amp;quot;acme_cert&amp;quot;,
      &amp;quot;domain&amp;quot;: [
        &amp;quot;YOUR_DOMAIN&amp;quot;
      ],
      &amp;quot;email&amp;quot;: &amp;quot;YOUR_EMAIL@example.com&amp;quot;,
      &amp;quot;data_directory&amp;quot;: &amp;quot;/var/lib/sing-box/certmagic&amp;quot;
    }
  ],
  &amp;quot;inbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;hysteria2&amp;quot;,
      &amp;quot;listen&amp;quot;: &amp;quot;::&amp;quot;,
      &amp;quot;listen_port&amp;quot;: 443,
      &amp;quot;users&amp;quot;: [
        {
          &amp;quot;password&amp;quot;: &amp;quot;CHANGE_THIS_TO_A_STRONG_PASSWORD&amp;quot;
        }
      ],
      &amp;quot;tls&amp;quot;: {
        &amp;quot;enabled&amp;quot;: true,
        &amp;quot;server_name&amp;quot;: &amp;quot;YOUR_DOMAIN&amp;quot;,
        &amp;quot;certificate_provider&amp;quot;: &amp;quot;acme_cert&amp;quot;
      }
    }
  ],
  &amp;quot;outbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;direct&amp;quot;
    }
  ]
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;&lt;code&gt;data_directory&lt;/code&gt; 必须在 &lt;code&gt;/var/lib/sing-box&lt;/code&gt; 下。省略时数据跟着 &lt;code&gt;sing-box&lt;/code&gt; 用户的 &lt;code&gt;HOME&lt;/code&gt; 走，重启后可能写不进去。&lt;code&gt;YOUR_DOMAIN&lt;/code&gt; 在 &lt;code&gt;domain[0]&lt;/code&gt; 和 &lt;code&gt;tls.server_name&lt;/code&gt; 两处必须一致。&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;&lt;tr&gt;
&lt;th&gt;配置项&lt;/th&gt;
&lt;th&gt;说明&lt;/th&gt;
&lt;/tr&gt;&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;certificate_providers[0].domain[0]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;解析到该 VPS 的域名&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;certificate_providers[0].email&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;邮箱&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;users[0].password&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;客户端密码&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;tls.server_name&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;与 &lt;code&gt;domain[0]&lt;/code&gt; 一致&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;listen&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;禁用 IPv6 时改为 &lt;code&gt;0.0.0.0&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;code&gt;up_mbps&lt;/code&gt; / &lt;code&gt;down_mbps&lt;/code&gt; 是服务端下发的 Brutal 上限，留空则不限速，且与 &lt;code&gt;ignore_client_bandwidth&lt;/code&gt; 互斥。未设带宽时，&lt;code&gt;ignore_client_bandwidth&lt;/code&gt; 让客户端改用 BBR；已设带宽时则禁止客户端用 BBR。&lt;code&gt;bbr_profile&lt;/code&gt; 可选 &lt;code&gt;conservative&lt;/code&gt;、&lt;code&gt;standard&lt;/code&gt;、&lt;code&gt;aggressive&lt;/code&gt;，默认 &lt;code&gt;standard&lt;/code&gt;。官方程序的 &lt;code&gt;userpass&lt;/code&gt; 在 sing-box 里要把 &lt;code&gt;username:password&lt;/code&gt; 整段当作密码。&lt;/p&gt;
&lt;p&gt;客户端自己的带宽字段是另一件事：留空则该客户端使用 BBR。&lt;/p&gt;
&lt;p&gt;混淆时两端的类型和密码必须一致。&lt;code&gt;gecko&lt;/code&gt; 还可设 &lt;code&gt;min_packet_size&lt;/code&gt;（默认 512）和 &lt;code&gt;max_packet_size&lt;/code&gt;（默认 1200）：&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-5&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-5&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;&amp;quot;obfs&amp;quot;: {
  &amp;quot;type&amp;quot;: &amp;quot;salamander&amp;quot;,
  &amp;quot;password&amp;quot;: &amp;quot;OBFS_PASSWORD&amp;quot;
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;未配置 &lt;code&gt;masquerade&lt;/code&gt; 时，认证失败返回 404。对象写法与字符串简写都还在：&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-6&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-6&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;&amp;quot;masquerade&amp;quot;: {
  &amp;quot;type&amp;quot;: &amp;quot;proxy&amp;quot;,
  &amp;quot;url&amp;quot;: &amp;quot;https://www.bing.com/&amp;quot;,
  &amp;quot;rewrite_host&amp;quot;: true
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-7&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-7&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;sudo chmod 600 /etc/sing-box/config.json
sudo sing-box check -c /etc/sing-box/config.json
sudo systemctl enable sing-box
sudo systemctl restart sing-box&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;日志：&lt;code&gt;sudo journalctl -u sing-box -e&lt;/code&gt;。&lt;/p&gt;
&lt;h2 id=&quot;客户端&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#客户端&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;客户端&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;本机代理是 &lt;code&gt;127.0.0.1:1080&lt;/code&gt;。ACME 证书不要加 &lt;code&gt;insecure&lt;/code&gt;。自签名应导入证书，&lt;code&gt;server_name&lt;/code&gt; 填证书里的伪装域名。&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-8&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-8&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;{
  &amp;quot;log&amp;quot;: {
    &amp;quot;level&amp;quot;: &amp;quot;info&amp;quot;,
    &amp;quot;timestamp&amp;quot;: true
  },
  &amp;quot;inbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;mixed&amp;quot;,
      &amp;quot;listen&amp;quot;: &amp;quot;127.0.0.1&amp;quot;,
      &amp;quot;listen_port&amp;quot;: 1080
    }
  ],
  &amp;quot;outbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;hysteria2&amp;quot;,
      &amp;quot;tag&amp;quot;: &amp;quot;hy2-out&amp;quot;,
      &amp;quot;server&amp;quot;: &amp;quot;YOUR_SERVER_IP&amp;quot;,
      &amp;quot;server_port&amp;quot;: 443,
      &amp;quot;password&amp;quot;: &amp;quot;CHANGE_THIS_TO_A_STRONG_PASSWORD&amp;quot;,
      &amp;quot;tls&amp;quot;: {
        &amp;quot;enabled&amp;quot;: true,
        &amp;quot;server_name&amp;quot;: &amp;quot;YOUR_DOMAIN&amp;quot;
      }
    }
  ]
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;服务端开了 &lt;code&gt;obfs&lt;/code&gt; 时，客户端要配同样的类型和密码。误用 Ed25519 证书会握手失败。可以临时设 &lt;code&gt;&amp;quot;disable_chrome_parrot&amp;quot;: true&lt;/code&gt; 做对比，生产环境应换 ECDSA 或 RSA 证书，而不是关掉鹦鹉。&lt;/p&gt;
&lt;h2 id=&quot;端口跳跃&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#端口跳跃&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;端口跳跃&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;示例把 UDP &lt;code&gt;20000:40000&lt;/code&gt; 转到本机 &lt;code&gt;9443&lt;/code&gt;，网卡是 &lt;code&gt;eth0&lt;/code&gt;。安全组放行这个 UDP 范围。DNAT 之后公网不必再放行 443 或 9443。&lt;/p&gt;
&lt;p&gt;把服务端 &lt;code&gt;listen_port&lt;/code&gt; 改成 &lt;code&gt;9443&lt;/code&gt; 并重启。然后：&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-9&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-9&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;sudo apt update
sudo apt install -y iptables-persistent
sudo iptables -t nat -A PREROUTING -i eth0 -p udp --dport 20000:40000 -j DNAT --to-destination :9443
sudo ip6tables -t nat -A PREROUTING -i eth0 -p udp --dport 20000:40000 -j DNAT --to-destination :9443
sudo netfilter-persistent save&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;网卡不是 &lt;code&gt;eth0&lt;/code&gt; 时，用 &lt;code&gt;ip route get 1.1.1.1&lt;/code&gt; 查看后替换。客户端只写 &lt;code&gt;server_ports&lt;/code&gt;，不要同时写 &lt;code&gt;server_port&lt;/code&gt;。&lt;code&gt;hop_interval&lt;/code&gt; 默认 &lt;code&gt;30s&lt;/code&gt;，需要随机间隔时再加 &lt;code&gt;hop_interval_max&lt;/code&gt;。&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-10&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-10&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;{
  &amp;quot;outbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;hysteria2&amp;quot;,
      &amp;quot;tag&amp;quot;: &amp;quot;hy2-out&amp;quot;,
      &amp;quot;server&amp;quot;: &amp;quot;YOUR_SERVER_IP&amp;quot;,
      &amp;quot;server_ports&amp;quot;: [
        &amp;quot;20000:40000&amp;quot;
      ],
      &amp;quot;hop_interval&amp;quot;: &amp;quot;30s&amp;quot;,
      &amp;quot;password&amp;quot;: &amp;quot;CHANGE_THIS_TO_A_STRONG_PASSWORD&amp;quot;,
      &amp;quot;tls&amp;quot;: {
        &amp;quot;enabled&amp;quot;: true,
        &amp;quot;server_name&amp;quot;: &amp;quot;YOUR_DOMAIN&amp;quot;
      }
    }
  ]
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;停用时删除对应 NAT 规则并 &lt;code&gt;netfilter-persistent save&lt;/code&gt;。&lt;/p&gt;
&lt;h2 id=&quot;排查&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#排查&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;排查&lt;/span&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;版本是否 ≥ 1.14.0，证书路径和权限是否可读，&lt;code&gt;data_directory&lt;/code&gt; 是否可由 &lt;code&gt;sing-box&lt;/code&gt; 用户写入。&lt;/li&gt;
&lt;li&gt;不要同时设置带宽字段和 &lt;code&gt;ignore_client_bandwidth&lt;/code&gt;。UDP 占用看 &lt;code&gt;sudo ss -lunp | grep -E ':443|:9443'&lt;/code&gt;。禁用 IPv6 时不要听 &lt;code&gt;::&lt;/code&gt;。&lt;/li&gt;
&lt;li&gt;只放行 TCP 不够，Hysteria2 走 UDP。自签名要导入证书，不要长期开 &lt;code&gt;insecure&lt;/code&gt;，也不要用 Ed25519。&lt;/li&gt;
&lt;li&gt;端口跳跃要求服务端听 &lt;code&gt;9443&lt;/code&gt;，客户端只有 &lt;code&gt;server_ports&lt;/code&gt;，DNAT 使用 UDP，IPv4 和 IPv6 都有规则，防火墙放行整个范围。&lt;/li&gt;
&lt;li&gt;不想限速就删掉 &lt;code&gt;up_mbps&lt;/code&gt; / &lt;code&gt;down_mbps&lt;/code&gt;。要客户端改用 BBR，只设 &lt;code&gt;&amp;quot;ignore_client_bandwidth&amp;quot;: true&lt;/code&gt;。&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;安全&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#安全&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;安全&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;密码用长随机值。&lt;code&gt;config.json&lt;/code&gt; 和 &lt;code&gt;server.key&lt;/code&gt; 权限 &lt;code&gt;600&lt;/code&gt;。优先 ACME。自签用 P-256 或 RSA。升级后重新执行 &lt;code&gt;sing-box check&lt;/code&gt;。&lt;/p&gt;
</description>
</item>
<item>
<title>Shadowsocks 部署指南（sing-box）</title>
<link>https://blog.onc.cc/post/shadowsocks-deploy</link>
<guid isPermaLink="true">https://blog.onc.cc/post/shadowsocks-deploy</guid>
<pubDate>Tue, 22 Sep 2026 00:00:00 GMT</pubDate>
<description>&lt;p&gt;Shadowsocks 2022（&lt;code&gt;2022-blake3-*&lt;/code&gt;）自带加密，没有 TLS，也不需要证书。旧版方法有重放风险，只用 2022 系列。需要 &lt;strong&gt;sing-box 1.14.0 及以上&lt;/strong&gt;。字段见 &lt;a href=&quot;https://sing-box.sagernet.org/configuration/inbound/shadowsocks/&quot;&gt;Shadowsocks inbound&lt;/a&gt;。&lt;/p&gt;
&lt;h2 id=&quot;准备&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#准备&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;准备&lt;/span&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;带 systemd 的 Linux VPS，有 root 或 &lt;code&gt;sudo&lt;/code&gt;；官方安装脚本覆盖 deb、rpm、Arch、OpenWrt。&lt;/li&gt;
&lt;li&gt;安全组和本机防火墙放行 TCP &lt;code&gt;443&lt;/code&gt;。需要 UDP 时一并放行。端口未被占用。&lt;/li&gt;
&lt;li&gt;一块长度符合加密方法的密钥。&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;安装&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#安装&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;安装&lt;/span&gt;&lt;/h2&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-1&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-1&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;curl -fsSL https://sing-box.app/install.sh | sh
sing-box version&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;版本必须 ≥ 1.14.0。&lt;/p&gt;
&lt;h2 id=&quot;密钥&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#密钥&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;密钥&lt;/span&gt;&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;&lt;tr&gt;
&lt;th&gt;加密方法&lt;/th&gt;
&lt;th&gt;密钥长度&lt;/th&gt;
&lt;th&gt;说明&lt;/th&gt;
&lt;/tr&gt;&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;2022-blake3-aes-128-gcm&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;16 字节&lt;/td&gt;
&lt;td&gt;有 AES 加速时优先&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;2022-blake3-aes-256-gcm&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;32 字节&lt;/td&gt;
&lt;td&gt;余量更大&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;2022-blake3-chacha20-poly1305&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;32 字节&lt;/td&gt;
&lt;td&gt;无 AES 加速时更快；不支持多用户&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-2&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-2&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;sing-box generate rand --base64 16
sing-box generate rand --base64 32&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;密钥必须与客户端完全一致，长度也必须匹配，否则服务起不来或连不上。&lt;/p&gt;
&lt;h2 id=&quot;服务端&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#服务端&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;服务端&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;写入 &lt;code&gt;/etc/sing-box/config.json&lt;/code&gt;：&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-3&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-3&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;{
  &amp;quot;log&amp;quot;: {
    &amp;quot;level&amp;quot;: &amp;quot;info&amp;quot;,
    &amp;quot;timestamp&amp;quot;: true
  },
  &amp;quot;inbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;shadowsocks&amp;quot;,
      &amp;quot;listen&amp;quot;: &amp;quot;::&amp;quot;,
      &amp;quot;listen_port&amp;quot;: 443,
      &amp;quot;method&amp;quot;: &amp;quot;2022-blake3-aes-128-gcm&amp;quot;,
      &amp;quot;password&amp;quot;: &amp;quot;CHANGE_THIS_TO_GENERATED_KEY&amp;quot;
    }
  ],
  &amp;quot;outbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;direct&amp;quot;
    }
  ]
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;table&gt;
&lt;thead&gt;&lt;tr&gt;
&lt;th&gt;配置项&lt;/th&gt;
&lt;th&gt;说明&lt;/th&gt;
&lt;/tr&gt;&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;password&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;生成的密钥，长度必须匹配加密方法&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;method&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;与客户端一致&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;listen_port&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;默认 &lt;code&gt;443&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;listen&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;默认 &lt;code&gt;::&lt;/code&gt;。禁用 IPv6 时改为 &lt;code&gt;0.0.0.0&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;code&gt;network&lt;/code&gt; 省略时同时监听 TCP 和 UDP。只要其一就写 &lt;code&gt;&amp;quot;tcp&amp;quot;&lt;/code&gt; 或 &lt;code&gt;&amp;quot;udp&amp;quot;&lt;/code&gt;，不要写 &lt;code&gt;&amp;quot;tcp,udp&amp;quot;&lt;/code&gt;，也不要写成数组。&lt;/p&gt;
&lt;p&gt;多路复用时，入站和出站使用同一段。开启 &lt;code&gt;padding&lt;/code&gt; 后，服务端会拒绝未填充的连接：&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-4&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-4&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;&amp;quot;multiplex&amp;quot;: {
  &amp;quot;enabled&amp;quot;: true,
  &amp;quot;padding&amp;quot;: true
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-5&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-5&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;sudo chmod 600 /etc/sing-box/config.json
sudo sing-box check -c /etc/sing-box/config.json
sudo systemctl enable sing-box
sudo systemctl restart sing-box&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;日志：&lt;code&gt;sudo journalctl -u sing-box -e&lt;/code&gt;。&lt;/p&gt;
&lt;h2 id=&quot;客户端&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#客户端&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;客户端&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;出站必须放在 &lt;code&gt;outbounds&lt;/code&gt; 里。本机代理是 &lt;code&gt;127.0.0.1:1080&lt;/code&gt;。&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-6&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-6&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;{
  &amp;quot;log&amp;quot;: {
    &amp;quot;level&amp;quot;: &amp;quot;info&amp;quot;,
    &amp;quot;timestamp&amp;quot;: true
  },
  &amp;quot;inbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;mixed&amp;quot;,
      &amp;quot;listen&amp;quot;: &amp;quot;127.0.0.1&amp;quot;,
      &amp;quot;listen_port&amp;quot;: 1080
    }
  ],
  &amp;quot;outbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;shadowsocks&amp;quot;,
      &amp;quot;tag&amp;quot;: &amp;quot;ss-out&amp;quot;,
      &amp;quot;server&amp;quot;: &amp;quot;YOUR_SERVER_IP&amp;quot;,
      &amp;quot;server_port&amp;quot;: 443,
      &amp;quot;method&amp;quot;: &amp;quot;2022-blake3-aes-128-gcm&amp;quot;,
      &amp;quot;password&amp;quot;: &amp;quot;CHANGE_THIS_TO_GENERATED_KEY&amp;quot;
    }
  ]
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;没有 TLS 段。&lt;code&gt;method&lt;/code&gt; 和 &lt;code&gt;password&lt;/code&gt; 必须与服务端一致。服务端开了 &lt;code&gt;multiplex&lt;/code&gt; 时，客户端也要配同样的段。&lt;/p&gt;
&lt;h2 id=&quot;多用户&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#多用户&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;多用户&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;顶层 &lt;code&gt;password&lt;/code&gt; 仍是服务端密钥，不能删。&lt;code&gt;2022-blake3-chacha20-poly1305&lt;/code&gt; 不能多用户。&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-7&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-7&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;{
  &amp;quot;inbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;shadowsocks&amp;quot;,
      &amp;quot;listen&amp;quot;: &amp;quot;::&amp;quot;,
      &amp;quot;listen_port&amp;quot;: 443,
      &amp;quot;method&amp;quot;: &amp;quot;2022-blake3-aes-128-gcm&amp;quot;,
      &amp;quot;password&amp;quot;: &amp;quot;SERVER_KEY&amp;quot;,
      &amp;quot;users&amp;quot;: [
        {
          &amp;quot;name&amp;quot;: &amp;quot;user1&amp;quot;,
          &amp;quot;password&amp;quot;: &amp;quot;USER1_KEY&amp;quot;
        },
        {
          &amp;quot;name&amp;quot;: &amp;quot;user2&amp;quot;,
          &amp;quot;password&amp;quot;: &amp;quot;USER2_KEY&amp;quot;
        }
      ]
    }
  ]
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;客户端 &lt;code&gt;password&lt;/code&gt; 是 &lt;code&gt;SERVER_KEY:USER_KEY&lt;/code&gt;，服务端密钥在前。&lt;/p&gt;
&lt;h2 id=&quot;排查&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#排查&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;排查&lt;/span&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;密钥长度：aes-128-gcm 是 16 字节 Base64，其余是 32 字节，且必须是合法 Base64。&lt;/li&gt;
&lt;li&gt;多用户时顶层 &lt;code&gt;password&lt;/code&gt; 仍必填。&lt;/li&gt;
&lt;li&gt;&lt;code&gt;network&lt;/code&gt; 不要写成 &lt;code&gt;&amp;quot;tcp,udp&amp;quot;&lt;/code&gt; 或数组。端口占用看 &lt;code&gt;sudo ss -lntup | grep ':443'&lt;/code&gt;。禁用 IPv6 时不要听 &lt;code&gt;::&lt;/code&gt;。&lt;/li&gt;
&lt;li&gt;客户端方法和密钥必须同一套。多用户时冒号顺序不能错。&lt;code&gt;multiplex&lt;/code&gt; 两侧一致。&lt;/li&gt;
&lt;li&gt;少量认证失败多半是扫描。持续失败就核对 Base64，包括结尾 &lt;code&gt;=&lt;/code&gt;；泄露后立刻换密钥。&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;安全&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#安全&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;安全&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;只用 2022 系列。&lt;code&gt;config.json&lt;/code&gt; 权限 &lt;code&gt;600&lt;/code&gt;。443 上没有 TLS，流量不像 HTTPS。升级后重新执行 &lt;code&gt;sing-box check&lt;/code&gt;。&lt;/p&gt;
</description>
</item>
<item>
<title>Snell v6 部署指南（sing-box）</title>
<link>https://blog.onc.cc/post/snell-v6-deploy</link>
<guid isPermaLink="true">https://blog.onc.cc/post/snell-v6-deploy</guid>
<pubDate>Tue, 22 Sep 2026 00:00:00 GMT</pubDate>
<description>&lt;p&gt;Snell v6 用 PSK 派生协议画像，并用 &lt;code&gt;mode&lt;/code&gt; 做流量整形。sing-box &lt;strong&gt;1.14.0&lt;/strong&gt; 起提供该入站。字段见 &lt;a href=&quot;https://sing-box.sagernet.org/configuration/inbound/snell/&quot;&gt;Snell inbound&lt;/a&gt; 与 &lt;a href=&quot;https://sing-box.sagernet.org/configuration/outbound/snell/&quot;&gt;outbound&lt;/a&gt;。&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;&lt;tr&gt;
&lt;th&gt;模式&lt;/th&gt;
&lt;th&gt;说明&lt;/th&gt;
&lt;/tr&gt;&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;default&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;默认整形，适合生产&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;unshaped&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;不做整形&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;unsafe-raw&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;明文调试，禁止用于生产&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;不要在多台服务器之间复用同一个 PSK。&lt;/p&gt;
&lt;h2 id=&quot;准备&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#准备&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;准备&lt;/span&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;带 systemd 的 Linux VPS，有 root 或 &lt;code&gt;sudo&lt;/code&gt;。官方安装脚本覆盖 deb、rpm、Arch、OpenWrt，不是任意发行版。&lt;/li&gt;
&lt;li&gt;安全组和本机防火墙放行 TCP &lt;code&gt;443&lt;/code&gt;，且端口未被占用。&lt;/li&gt;
&lt;li&gt;一串 12–255 字节的随机 PSK。&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;安装&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#安装&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;安装&lt;/span&gt;&lt;/h2&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-1&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-1&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;curl -fsSL https://sing-box.app/install.sh | sh
sing-box version&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;版本必须 ≥ 1.14.0，否则识别不了 &lt;code&gt;snell&lt;/code&gt;。&lt;/p&gt;
&lt;h2 id=&quot;psk&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#psk&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;PSK&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;长度按字符串本身计算，推荐 32 字节随机值的 Base64：&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-2&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-2&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;sing-box generate rand --base64 32&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;不要用短口令，也不要让 Base64 文本超过 255 字节。&lt;/p&gt;
&lt;h2 id=&quot;服务端&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#服务端&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;服务端&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;写入 &lt;code&gt;/etc/sing-box/config.json&lt;/code&gt;：&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-3&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-3&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;{
  &amp;quot;log&amp;quot;: {
    &amp;quot;level&amp;quot;: &amp;quot;info&amp;quot;,
    &amp;quot;timestamp&amp;quot;: true
  },
  &amp;quot;inbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;snell&amp;quot;,
      &amp;quot;listen&amp;quot;: &amp;quot;::&amp;quot;,
      &amp;quot;listen_port&amp;quot;: 443,
      &amp;quot;version&amp;quot;: 6,
      &amp;quot;psk&amp;quot;: &amp;quot;CHANGE_THIS_TO_A_GENERATED_PSK&amp;quot;
    }
  ],
  &amp;quot;outbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;direct&amp;quot;
    }
  ]
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;table&gt;
&lt;thead&gt;&lt;tr&gt;
&lt;th&gt;配置项&lt;/th&gt;
&lt;th&gt;说明&lt;/th&gt;
&lt;/tr&gt;&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;psk&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;12–255 字节的随机值&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;listen_port&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;默认 &lt;code&gt;443&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;listen&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;禁用 IPv6、报 &lt;code&gt;cannot assign requested address&lt;/code&gt; 时改为 &lt;code&gt;0.0.0.0&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;code&gt;mode&lt;/code&gt; 默认 &lt;code&gt;default&lt;/code&gt;，不清楚影响就不要改。&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-4&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-4&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;sudo chmod 600 /etc/sing-box/config.json
sudo sing-box check -c /etc/sing-box/config.json
sudo systemctl enable sing-box
sudo systemctl restart sing-box&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;日志：&lt;code&gt;sudo journalctl -u sing-box -e&lt;/code&gt;。&lt;/p&gt;
&lt;h2 id=&quot;多用户&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#多用户&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;多用户&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;顶层 &lt;code&gt;psk&lt;/code&gt; 仍是服务器密钥。每个用户用自己的 &lt;code&gt;userkey&lt;/code&gt;。&lt;code&gt;name&lt;/code&gt; 只用于日志。&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-5&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-5&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;{
  &amp;quot;inbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;snell&amp;quot;,
      &amp;quot;listen&amp;quot;: &amp;quot;::&amp;quot;,
      &amp;quot;listen_port&amp;quot;: 443,
      &amp;quot;version&amp;quot;: 6,
      &amp;quot;psk&amp;quot;: &amp;quot;SERVER_PSK&amp;quot;,
      &amp;quot;users&amp;quot;: [
        {
          &amp;quot;name&amp;quot;: &amp;quot;user1&amp;quot;,
          &amp;quot;userkey&amp;quot;: &amp;quot;USER1_KEY&amp;quot;
        }
      ]
    }
  ]
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;客户端同时填写顶层 &lt;code&gt;psk&lt;/code&gt; 和该用户的 &lt;code&gt;userkey&lt;/code&gt;。&lt;/p&gt;
&lt;h2 id=&quot;客户端&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#客户端&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;客户端&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;本机代理是 &lt;code&gt;127.0.0.1:1080&lt;/code&gt;。协议没有 TLS。&lt;code&gt;mode&lt;/code&gt; 必须与服务端一致。&lt;code&gt;reuse&lt;/code&gt; 是出站字段，默认关闭，需要连接复用时再设为 &lt;code&gt;true&lt;/code&gt;。&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-6&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-6&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;{
  &amp;quot;log&amp;quot;: {
    &amp;quot;level&amp;quot;: &amp;quot;info&amp;quot;,
    &amp;quot;timestamp&amp;quot;: true
  },
  &amp;quot;inbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;mixed&amp;quot;,
      &amp;quot;listen&amp;quot;: &amp;quot;127.0.0.1&amp;quot;,
      &amp;quot;listen_port&amp;quot;: 1080
    }
  ],
  &amp;quot;outbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;snell&amp;quot;,
      &amp;quot;tag&amp;quot;: &amp;quot;snell-out&amp;quot;,
      &amp;quot;server&amp;quot;: &amp;quot;YOUR_SERVER_IP&amp;quot;,
      &amp;quot;server_port&amp;quot;: 443,
      &amp;quot;psk&amp;quot;: &amp;quot;CHANGE_THIS_TO_A_GENERATED_PSK&amp;quot;,
      &amp;quot;version&amp;quot;: 6
    }
  ]
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;排查&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#排查&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;排查&lt;/span&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;版本是否 ≥ 1.14.0，&lt;code&gt;version&lt;/code&gt; 是否为数字 &lt;code&gt;6&lt;/code&gt;，PSK 是否落在 12–255 字节。&lt;/li&gt;
&lt;li&gt;端口占用看 &lt;code&gt;sudo ss -lntp | grep ':443'&lt;/code&gt;。禁用 IPv6 时不要听 &lt;code&gt;::&lt;/code&gt;。&lt;/li&gt;
&lt;li&gt;客户端地址、端口、PSK 一致。多用户还要填对 &lt;code&gt;userkey&lt;/code&gt;。两端 &lt;code&gt;mode&lt;/code&gt; 一致。&lt;/li&gt;
&lt;li&gt;&lt;code&gt;unsafe-raw&lt;/code&gt; 不加密，只用于本地调试。出现 &lt;code&gt;unknown inbound type&lt;/code&gt; 或 &lt;code&gt;unsupported version&lt;/code&gt; 时，升级到 1.14.0 及以上再试。&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;安全&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#安全&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;安全&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;PSK 用生成命令，不要短口令，也不要多机复用。&lt;code&gt;config.json&lt;/code&gt; 权限 &lt;code&gt;600&lt;/code&gt;。不要在生产环境使用 &lt;code&gt;unsafe-raw&lt;/code&gt;。443 上没有 TLS。升级后重新执行 &lt;code&gt;sing-box check&lt;/code&gt;。&lt;/p&gt;
</description>
</item>
<item>
<title>VLESS 部署指南（sing-box）</title>
<link>https://blog.onc.cc/post/vless-deploy</link>
<guid isPermaLink="true">https://blog.onc.cc/post/vless-deploy</guid>
<pubDate>Tue, 22 Sep 2026 00:00:00 GMT</pubDate>
<description>&lt;p&gt;VLESS + Reality + &lt;code&gt;xtls-rprx-vision&lt;/code&gt;：不需要域名和证书，握手伪装成普通 HTTPS。需要 &lt;strong&gt;sing-box 1.14.0 及以上&lt;/strong&gt;。字段见 &lt;a href=&quot;https://sing-box.sagernet.org/configuration/inbound/vless/&quot;&gt;VLESS inbound&lt;/a&gt; 与 &lt;a href=&quot;https://sing-box.sagernet.org/configuration/shared/tls/&quot;&gt;TLS / Reality&lt;/a&gt;。&lt;/p&gt;
&lt;h2 id=&quot;准备&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#准备&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;准备&lt;/span&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;带 systemd 的 Linux VPS，有 root 或 &lt;code&gt;sudo&lt;/code&gt;；官方安装脚本覆盖 deb、rpm、Arch、OpenWrt。&lt;/li&gt;
&lt;li&gt;安全组和本机防火墙放行 TCP &lt;code&gt;443&lt;/code&gt;，且端口未被占用。&lt;/li&gt;
&lt;li&gt;VPS 能出站访问 443，Reality 握手要转发到伪装站点。&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;安装&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#安装&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;安装&lt;/span&gt;&lt;/h2&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-1&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-1&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;curl -fsSL https://sing-box.app/install.sh | sh
sing-box version&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;版本必须 ≥ 1.14.0。&lt;/p&gt;
&lt;h2 id=&quot;密钥&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#密钥&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;密钥&lt;/span&gt;&lt;/h2&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-2&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-2&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;sing-box generate reality-keypair
sing-box generate uuid
openssl rand -hex 4&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;&lt;code&gt;PrivateKey&lt;/code&gt; 只放服务端，&lt;code&gt;PublicKey&lt;/code&gt; 给客户端。不要手编 UUID。&lt;code&gt;short_id&lt;/code&gt; 是偶数长度的十六进制，解码后不超过 8 字节，也就是最多 16 个字符。&lt;/p&gt;
&lt;h2 id=&quot;服务端&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#服务端&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;服务端&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;写入 &lt;code&gt;/etc/sing-box/config.json&lt;/code&gt;。使用 Vision 时不要开 &lt;code&gt;multiplex&lt;/code&gt;。&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-3&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-3&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;{
  &amp;quot;log&amp;quot;: {
    &amp;quot;level&amp;quot;: &amp;quot;info&amp;quot;,
    &amp;quot;timestamp&amp;quot;: true
  },
  &amp;quot;inbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;vless&amp;quot;,
      &amp;quot;listen&amp;quot;: &amp;quot;::&amp;quot;,
      &amp;quot;listen_port&amp;quot;: 443,
      &amp;quot;users&amp;quot;: [
        {
          &amp;quot;uuid&amp;quot;: &amp;quot;CHANGE_THIS_TO_GENERATED_UUID&amp;quot;,
          &amp;quot;flow&amp;quot;: &amp;quot;xtls-rprx-vision&amp;quot;
        }
      ],
      &amp;quot;tls&amp;quot;: {
        &amp;quot;enabled&amp;quot;: true,
        &amp;quot;server_name&amp;quot;: &amp;quot;www.microsoft.com&amp;quot;,
        &amp;quot;reality&amp;quot;: {
          &amp;quot;enabled&amp;quot;: true,
          &amp;quot;handshake&amp;quot;: {
            &amp;quot;server&amp;quot;: &amp;quot;www.microsoft.com&amp;quot;,
            &amp;quot;server_port&amp;quot;: 443
          },
          &amp;quot;private_key&amp;quot;: &amp;quot;CHANGE_THIS_TO_PRIVATE_KEY&amp;quot;,
          &amp;quot;short_id&amp;quot;: [
            &amp;quot;CHANGE_THIS_TO_SHORT_ID&amp;quot;
          ]
        }
      }
    }
  ],
  &amp;quot;outbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;direct&amp;quot;
    }
  ]
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;table&gt;
&lt;thead&gt;&lt;tr&gt;
&lt;th&gt;配置项&lt;/th&gt;
&lt;th&gt;填入&lt;/th&gt;
&lt;/tr&gt;&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;users[0].uuid&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sing-box generate uuid&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;tls.reality.private_key&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;密钥对里的 &lt;code&gt;PrivateKey&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;tls.reality.short_id&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;openssl rand -hex 4&lt;/code&gt; 的输出&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;tls.server_name&lt;/code&gt; / &lt;code&gt;handshake.server&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;同一个伪装站点&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;listen&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;禁用 IPv6 时改为 &lt;code&gt;0.0.0.0&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;伪装站选支持 TLS 1.3 和 HTTP/2、且 VPS 能访问的站点，不要用自己控制或容易关停的站。&lt;code&gt;server_name&lt;/code&gt;、&lt;code&gt;handshake.server&lt;/code&gt; 和客户端 &lt;code&gt;server_name&lt;/code&gt; 必须一致。先用 &lt;code&gt;curl -I&lt;/code&gt; 确认出站可达。&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-4&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-4&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;sudo chmod 600 /etc/sing-box/config.json
sudo sing-box check -c /etc/sing-box/config.json
sudo systemctl enable sing-box
sudo systemctl restart sing-box&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;日志：&lt;code&gt;sudo journalctl -u sing-box -e&lt;/code&gt;。&lt;/p&gt;
&lt;h2 id=&quot;客户端&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#客户端&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;客户端&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;本机代理是 &lt;code&gt;127.0.0.1:1080&lt;/code&gt;。官方把 uTLS 标为不推荐，字段仍在，示例继续用 &lt;code&gt;chrome&lt;/code&gt;。&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-5&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-5&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;json&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;{
  &amp;quot;log&amp;quot;: {
    &amp;quot;level&amp;quot;: &amp;quot;info&amp;quot;,
    &amp;quot;timestamp&amp;quot;: true
  },
  &amp;quot;inbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;mixed&amp;quot;,
      &amp;quot;listen&amp;quot;: &amp;quot;127.0.0.1&amp;quot;,
      &amp;quot;listen_port&amp;quot;: 1080
    }
  ],
  &amp;quot;outbounds&amp;quot;: [
    {
      &amp;quot;type&amp;quot;: &amp;quot;vless&amp;quot;,
      &amp;quot;tag&amp;quot;: &amp;quot;vless-out&amp;quot;,
      &amp;quot;server&amp;quot;: &amp;quot;YOUR_SERVER_IP&amp;quot;,
      &amp;quot;server_port&amp;quot;: 443,
      &amp;quot;uuid&amp;quot;: &amp;quot;CHANGE_THIS_TO_GENERATED_UUID&amp;quot;,
      &amp;quot;flow&amp;quot;: &amp;quot;xtls-rprx-vision&amp;quot;,
      &amp;quot;tls&amp;quot;: {
        &amp;quot;enabled&amp;quot;: true,
        &amp;quot;server_name&amp;quot;: &amp;quot;www.microsoft.com&amp;quot;,
        &amp;quot;utls&amp;quot;: {
          &amp;quot;enabled&amp;quot;: true,
          &amp;quot;fingerprint&amp;quot;: &amp;quot;chrome&amp;quot;
        },
        &amp;quot;reality&amp;quot;: {
          &amp;quot;enabled&amp;quot;: true,
          &amp;quot;public_key&amp;quot;: &amp;quot;CHANGE_THIS_TO_PUBLIC_KEY&amp;quot;,
          &amp;quot;short_id&amp;quot;: &amp;quot;CHANGE_THIS_TO_SHORT_ID&amp;quot;
        }
      }
    }
  ]
}&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;客户端 &lt;code&gt;short_id&lt;/code&gt; 是字符串，取服务端数组中的一项。&lt;code&gt;flow&lt;/code&gt; 要么两端都开，要么都不开。&lt;/p&gt;
&lt;p&gt;多用户时在 &lt;code&gt;users&lt;/code&gt; 里加独立 UUID，共用同一组 Reality 密钥和 &lt;code&gt;short_id&lt;/code&gt;。Reality 不申请证书：握手借用伪装站，服务端只保存自己的密钥对。&lt;/p&gt;
&lt;h2 id=&quot;排查&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#排查&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;排查&lt;/span&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;private_key&lt;/code&gt; 要完整，结尾不要带引号或空格。&lt;code&gt;short_id&lt;/code&gt; 必须是偶数长度，且不超过 16 个十六进制字符。&lt;/li&gt;
&lt;li&gt;UUID 必须有效。Vision 下不要开 &lt;code&gt;multiplex&lt;/code&gt;。端口占用看 &lt;code&gt;sudo ss -lntp | grep ':443'&lt;/code&gt;。禁用 IPv6 时不要听 &lt;code&gt;::&lt;/code&gt;。&lt;/li&gt;
&lt;li&gt;客户端的 &lt;code&gt;uuid&lt;/code&gt;、&lt;code&gt;flow&lt;/code&gt;、&lt;code&gt;server_name&lt;/code&gt;、&lt;code&gt;public_key&lt;/code&gt;、&lt;code&gt;short_id&lt;/code&gt; 与服务端一致。安全组放行 TCP 443。&lt;/li&gt;
&lt;li&gt;时间差过大也会握手失败。&lt;code&gt;tls.reality.max_time_difference&lt;/code&gt; 省略时不检查；需要放宽时用官方示例 &lt;code&gt;1m&lt;/code&gt;。&lt;/li&gt;
&lt;li&gt;出站访问不了伪装站就换 &lt;code&gt;handshake.server&lt;/code&gt;：&lt;code&gt;curl -I --max-time 10 https://www.microsoft.com&lt;/code&gt;。&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;安全&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#安全&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;安全&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;UUID、密钥对和 &lt;code&gt;short_id&lt;/code&gt; 都用生成命令，不要手编。&lt;code&gt;config.json&lt;/code&gt; 权限 &lt;code&gt;600&lt;/code&gt;。私钥只留在服务端。Vision 不要搭配 &lt;code&gt;multiplex&lt;/code&gt;。升级后重新执行 &lt;code&gt;sing-box check&lt;/code&gt;。&lt;/p&gt;
</description>
</item>
<item>
<title>Debian 手动创建 Swap 文件</title>
<link>https://blog.onc.cc/post/debian-create-swap</link>
<guid isPermaLink="true">https://blog.onc.cc/post/debian-create-swap</guid>
<pubDate>Sun, 02 Aug 2026 00:00:00 GMT</pubDate>
<description>&lt;p&gt;Swap 可在内存不足时提供磁盘缓冲，但速度远低于 RAM。以下命令需使用 &lt;code&gt;root&lt;/code&gt;，示例创建 1 GB Swap。&lt;/p&gt;
&lt;h2 id=&quot;检查状态&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#检查状态&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;检查状态&lt;/span&gt;&lt;/h2&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-1&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-1&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;swapon --show
free -h&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;创建并启用&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#创建并启用&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;创建并启用&lt;/span&gt;&lt;/h2&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-2&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-2&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;fallocate -l 1G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;若 &lt;code&gt;fallocate&lt;/code&gt; 创建的文件无法启用，改用：&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-3&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-3&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;dd if=/dev/zero of=/swapfile bs=1M count=1024 status=progress
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;用 &lt;code&gt;swapon --show&lt;/code&gt; 确认。&lt;/p&gt;
&lt;h2 id=&quot;设置开机启用&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#设置开机启用&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;设置开机启用&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;确认没有重复配置后，再追加到 &lt;code&gt;/etc/fstab&lt;/code&gt;：&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-4&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-4&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;echo '/swapfile none swap sw 0 0' &amp;gt;&amp;gt; /etc/fstab
findmnt --verify&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;调整-swappiness&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#调整-swappiness&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;调整 Swappiness&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;服务器可按负载将默认值 &lt;code&gt;60&lt;/code&gt; 调低到 &lt;code&gt;10&lt;/code&gt;：&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-5&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-5&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;echo 'vm.swappiness=10' &amp;gt; /etc/sysctl.d/99-swappiness.conf
sysctl --system
sysctl vm.swappiness&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;长期频繁使用 Swap，通常说明内存不足，应优先优化应用或增加 RAM。&lt;/p&gt;
&lt;h2 id=&quot;删除&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#删除&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;删除&lt;/span&gt;&lt;/h2&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-6&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-6&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;swapoff /swapfile
# 从 /etc/fstab 删除对应行
rm -f /swapfile
swapon --show
free -h&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;激活失败时，检查文件权限是否为 &lt;code&gt;600&lt;/code&gt;，并查看 &lt;code&gt;dmesg | tail -n 30&lt;/code&gt;。&lt;/p&gt;
</description>
</item>
<item>
<title>你好，Rust</title>
<link>https://blog.onc.cc/post/hello</link>
<guid isPermaLink="true">https://blog.onc.cc/post/hello</guid>
<pubDate>Sat, 01 Aug 2026 00:00:00 GMT</pubDate>
<description>&lt;p&gt;这是第一篇笔记：一个只用 Rust 标准库的静态博客生成器，当前是 Rust 1.98 与 2024 edition。&lt;/p&gt;
&lt;h2 id=&quot;它能渲染什么&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#它能渲染什么&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;它能渲染什么&lt;/span&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;带空格的 ATX 标题、列表、引用、表格、图片和围栏代码块&lt;/li&gt;
&lt;li&gt;RSS、sitemap、归档页和文章目录&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;添加文章&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#添加文章&quot; aria-label=&quot;链接到此标题&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;heading-text&quot;&gt;添加文章&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;在 &lt;code&gt;content/&lt;/code&gt; 放一个 Markdown 文件，文件名会成为 slug：&lt;/p&gt;
&lt;figure class=&quot;code-window&quot; aria-labelledby=&quot;code-1&quot;&gt;&lt;figcaption class=&quot;code-window-bar&quot; id=&quot;code-1&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;markdown&lt;/span&gt;&lt;button class=&quot;code-copy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;Copy&lt;/button&gt;&lt;/figcaption&gt;&lt;pre tabindex=&quot;0&quot;&gt;&lt;code&gt;---
title: 新文章标题
date: 2026-08-01
time: 09:30
---
正文从这里开始。&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;&lt;code&gt;time&lt;/code&gt; 可选，按 UTC 写入 feed。没有 &lt;code&gt;date&lt;/code&gt; 的文章排在最后，sitemap 也不写 &lt;code&gt;lastmod&lt;/code&gt;。&lt;/p&gt;
</description>
</item>
</channel></rss>
