<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh">
	<id>https://md5.pw/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=AlexLynn</id>
	<title>md5.pw - 用户贡献 [zh]</title>
	<link rel="self" type="application/atom+xml" href="https://md5.pw/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=AlexLynn"/>
	<link rel="alternate" type="text/html" href="https://md5.pw/index.php?title=Special:%E7%94%A8%E6%88%B7%E8%B4%A1%E7%8C%AE/AlexLynn"/>
	<updated>2026-05-06T15:17:25Z</updated>
	<subtitle>用户贡献</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://md5.pw/index.php?title=User:AlexLynn&amp;diff=1486</id>
		<title>User:AlexLynn</title>
		<link rel="alternate" type="text/html" href="https://md5.pw/index.php?title=User:AlexLynn&amp;diff=1486"/>
		<updated>2026-03-01T23:35:15Z</updated>

		<summary type="html">&lt;p&gt;AlexLynn：​创建页面，内容为“A simple user of BWH since 2018.”&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A simple user of BWH since 2018.&lt;/div&gt;</summary>
		<author><name>AlexLynn</name></author>
	</entry>
	<entry>
		<id>https://md5.pw/index.php?title=BWH_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1485</id>
		<title>BWH CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术</title>
		<link rel="alternate" type="text/html" href="https://md5.pw/index.php?title=BWH_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1485"/>
		<updated>2026-03-01T06:10:54Z</updated>

		<summary type="html">&lt;p&gt;AlexLynn：​&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术 =&lt;br /&gt;
= BandwagonHost CN2 GIA &amp;amp; Komari: A Lightweight Go Probe Presenting the Art of Top-Tier Networking =&lt;br /&gt;
&lt;br /&gt;
搬瓦工（BandwagonHost）的 CN2 GIA 线路堪称 VPS 界的网络天花板。其三网顶级直连架构不仅带来了令人惊叹的极致超低延迟，更是在晚高峰也能保持全天候 &#039;&#039;&#039;0 丢包&#039;&#039;&#039; 的神话。这种丝滑、纯粹的网络体验，如果不配上一个优秀的现代监控探针将其彻底可视化，简直是暴殄天物！&lt;br /&gt;
BandwagonHost&#039;s CN2 GIA routing is arguably the network ceiling of the VPS world. Its top-tier direct connection across all three major networks brings not only amazingly stable and low latency but also maintains a mythical &#039;&#039;&#039;0 packet loss&#039;&#039;&#039; even during peak hours. Such a silky-smooth and pure network experience would be an absolute waste if not thoroughly visualized with an excellent modern monitoring dashboard!&lt;br /&gt;
&lt;br /&gt;
为了不辜负瓦工如此顶级的线路，我们需要一款同样极致的探针。今天的主角 &#039;&#039;&#039;Komari&#039;&#039;&#039; 正是为此而生。&lt;br /&gt;
To live up to such top-tier routing from BandwagonHost, we need an equally ultimate probe. Today&#039;s protagonist, &#039;&#039;&#039;Komari&#039;&#039;&#039;, was born for this exact purpose.&lt;br /&gt;
&lt;br /&gt;
== 为什么选择 Komari？ / Why Choose Komari? ==&lt;br /&gt;
&lt;br /&gt;
[[File:Komari.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
市面上的服务器监控面板琳琅满目，但 Komari 凭借其独特的架构脱颖而出：&lt;br /&gt;
The market is full of server monitoring panels, but Komari stands out with its unique architecture:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;基于 Go 语言构建 / Built with Go&#039;&#039;&#039;：Komari 的主控端和 Agent 均采用 Golang 编写。天生的高并发优势和出色的内存管理，使得它能以极低的系统资源占用，轻松处理并发连接。&amp;lt;br&amp;gt;Komari&#039;s controller and agent are both written in Golang. Its inherent high-concurrency advantages and excellent memory management allow it to easily handle concurrent connections with extremely low system resource consumption.&lt;br /&gt;
* &#039;&#039;&#039;优雅的 Controller + Agent 架构 / Elegant Controller + Agent Architecture&#039;&#039;&#039;：主控面板（Controller）负责节点管理与数据展示，轻量 Agent 负责采集系统指标，并通过 WebSocket 持久连接上报数据。这种设计避免了传统轮询式监控产生的大量请求开销，在低带宽 VPS 环境下依然能够保持高实时性与极低资源占用。&amp;lt;br&amp;gt;The controller dashboard is responsible for node management and data presentation, while the lightweight Agent collects system metrics and reports data via persistent WebSocket connections. This design avoids the massive request overhead generated by traditional polling-based monitoring, maintaining high real-time performance and extremely low resource usage even in low-bandwidth VPS environments.&lt;br /&gt;
* &#039;&#039;&#039;极致轻量与极简主义 / Extreme Lightweight &amp;amp; Minimalism&#039;&#039;&#039;：监控工具本身不应成为服务器的负担。Komari 没有臃肿的依赖库，对于极其珍贵的瓦工服务器资源来说，运行它几乎是“零感知”的。&amp;lt;br&amp;gt;Monitoring tools themselves shouldn&#039;t be a burden on the server. Komari has no bloated dependency libraries; for the extremely precious BandwagonHost server resources, running it is almost &amp;quot;zero-perception&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
本文将通过严谨的逻辑，一步一步完成 Komari 的基础部署、高级安全反代，以及多节点 Agent 的接入。&lt;br /&gt;
This article will walk through the basic deployment of Komari, advanced secure reverse proxy configuration, and multi-node Agent integration, step-by-step with rigorous logic.&lt;br /&gt;
&lt;br /&gt;
== 第一步：基础安装 - 部署 Komari 主控 / Step 1: Basic Installation - Deploying Komari Controller ==&lt;br /&gt;
&lt;br /&gt;
无论你是在白天使用 Windows 办公，还是使用 macOS 的终端，请先通过 SSH 接入你的搬瓦工服务器。为了保证环境的隔离性和未来排错的便利性，我们采用 Docker Compose 进行部署。&lt;br /&gt;
Whether you are working on Windows during the day or using the macOS terminal, please SSH into your BandwagonHost server first. To ensure environmental isolation and ease of future troubleshooting, we will deploy using Docker Compose.&lt;br /&gt;
&lt;br /&gt;
=== 1. 创建项目目录结构 / Create Project Directory Structure ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /opt/komari &amp;amp;&amp;amp; cd /opt/komari&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. 编写 Docker Compose 配置文件 / Write the Docker Compose Configuration ===&lt;br /&gt;
创建并编辑 Docker Compose 配置文件：&lt;br /&gt;
Create and edit the Docker Compose configuration file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano docker-compose.yml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下内容（注意端口映射的安全加固与版本控制）：&lt;br /&gt;
Write the following content (note the security hardening of port mapping and version control):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
version: &#039;3.8&#039;&lt;br /&gt;
services:&lt;br /&gt;
  komari:&lt;br /&gt;
    # 生产环境建议将 latest 替换为具体的 release 版本号以保证系统稳定性&lt;br /&gt;
    # For production, it&#039;s recommended to replace &#039;latest&#039; with a specific release version to ensure system stability&lt;br /&gt;
    image: ghcr.io/komari-monitor/komari:latest&lt;br /&gt;
    container_name: komari&lt;br /&gt;
    restart: unless-stopped&lt;br /&gt;
    ports:&lt;br /&gt;
      - &amp;quot;127.0.0.1:25774:25774&amp;quot;&lt;br /&gt;
    volumes:&lt;br /&gt;
      - ./data:/app/data&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与安全分析逻辑 / Debugging &amp;amp; Security Analysis Logic&lt;br /&gt;
: &#039;&#039;&#039;为什么映射 `/app/data`？ / Why map `/app/data`?&#039;&#039;&#039; 探针的面板设置、节点信息都物理存储在这个目录。如果不做映射，一旦容器重启或销毁，所有配置数据将全部丢失。 (The panel settings and node information are physically stored in this directory. If not mapped, all configuration data will be completely lost once the container restarts or is destroyed.)&lt;br /&gt;
: &#039;&#039;&#039;安全加固 `127.0.0.1`： / Security Hardening `127.0.0.1`:&#039;&#039;&#039; 绑定本地环回地址 `127.0.0.1`，杜绝被批量扫描及 0day 漏洞攻击的潜在威胁。 (Binding to the local loopback address `127.0.0.1` eliminates the potential threat of being bulk-scanned and attacked by 0-day vulnerabilities.)&lt;br /&gt;
&lt;br /&gt;
=== 3. 启动服务 / Start the Service ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker compose up -d&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
启动后，执行 `docker logs komari` 查看系统自动生成的初始管理员账号和密码。&lt;br /&gt;
After starting, execute `docker logs komari` to view the initial admin account and password automatically generated by the system.&lt;br /&gt;
&lt;br /&gt;
== 第二步：进阶配置 - Caddy 详尽反代与 HTTPS / Step 2: Advanced Configuration - Detailed Caddy Reverse Proxy &amp;amp; HTTPS ==&lt;br /&gt;
&lt;br /&gt;
在前端，我们将使用 Caddy 申请免费证书并进行反向代理，将安全的 HTTPS 流量转发给内网的 Komari。&lt;br /&gt;
On the frontend, we will use Caddy to request a free certificate and set up a reverse proxy to forward secure HTTPS traffic to the internal Komari service.&lt;br /&gt;
&lt;br /&gt;
=== 1. 编辑 Caddyfile / Edit the Caddyfile ===&lt;br /&gt;
打开你的 Caddy 配置文件（通常位于 `/etc/caddy/Caddyfile`）：&lt;br /&gt;
Open your Caddy config file (usually located at `/etc/caddy/Caddyfile`):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下配置（请将 `status.yourdomain.com` 替换为你的真实域名）：&lt;br /&gt;
Write the following configuration (please replace `status.yourdomain.com` with your real domain name):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
status.yourdomain.com {&lt;br /&gt;
    # 启用现代 TLS 协议 / Enable modern TLS protocols&lt;br /&gt;
    tls {&lt;br /&gt;
        protocols tls1.2 tls1.3&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 反向代理至本地环回地址的 Komari 端口 / Reverse proxy to the Komari port on the local loopback address&lt;br /&gt;
    reverse_proxy localhost:25774 {&lt;br /&gt;
        # 传递真实访客 IP 和协议 / Pass real visitor IP and protocol&lt;br /&gt;
        header_up Host {host}&lt;br /&gt;
        header_up X-Real-IP {remote}&lt;br /&gt;
        header_up X-Forwarded-For {remote}&lt;br /&gt;
        header_up X-Forwarded-Proto {scheme}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    # 启用压缩机制以加快探针面板加载速度 / Enable compression to speed up dashboard loading&lt;br /&gt;
    encode gzip zstd&lt;br /&gt;
&lt;br /&gt;
    # 现代且严谨的安全响应头设置 / Modern and rigorous security response headers setup&lt;br /&gt;
    header {&lt;br /&gt;
        # 注意：此处未加 preload，只有在你准备将域名提交到浏览器 HSTS preload list 时才建议加入 preload 参数&lt;br /&gt;
        # Note: &#039;preload&#039; is omitted here; it is only recommended if you plan to submit the domain to the browser HSTS preload list&lt;br /&gt;
        Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        X-Content-Type-Options &amp;quot;nosniff&amp;quot;&lt;br /&gt;
        X-Frame-Options &amp;quot;SAMEORIGIN&amp;quot;&lt;br /&gt;
        Referrer-Policy &amp;quot;strict-origin-when-cross-origin&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 详尽的访问日志记录，为未来排错提供明确的数据分析支持 / Detailed access logging to provide clear data support for future debugging&lt;br /&gt;
    log {&lt;br /&gt;
        output file /var/log/caddy/komari_access.log {&lt;br /&gt;
            roll_size 100mb&lt;br /&gt;
            roll_keep 5&lt;br /&gt;
        }&lt;br /&gt;
        format json&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与排错逻辑 / Debugging &amp;amp; Troubleshooting Logic&lt;br /&gt;
: &#039;&#039;&#039;WebSocket 断连与 Cloudflare 避坑： / WebSocket Disconnection &amp;amp; Cloudflare Pitfalls:&#039;&#039;&#039; Komari 极其依赖 WebSocket 进行实时数据推送（Caddy v2 默认原生支持 WebSocket 转发）。如果你发现面板卡死不刷新，请首先检查链路。如果你在前端套用了 Cloudflare，请务必检查：1. 网络设置中的 &amp;quot;WebSockets&amp;quot; 选项是否开启；2. SSL/TLS 加密模式必须设置为 &amp;quot;Full&amp;quot; 或 &amp;quot;Full (Strict)&amp;quot;，否则会导致循环重定向或握手失败。 (Komari heavily relies on WebSocket for real-time data push. If the panel freezes, check the link first. If using Cloudflare, ensure: 1. &amp;quot;WebSockets&amp;quot; is enabled in Network settings; 2. SSL/TLS mode is set to &amp;quot;Full&amp;quot; or &amp;quot;Full (Strict)&amp;quot; to prevent redirect loops or handshake failures.)&lt;br /&gt;
: &#039;&#039;&#039;日志分析排错： / Log Analysis Troubleshooting:&#039;&#039;&#039; 这里专门配置了 `/var/log/caddy/komari_access.log`。如果配置完出现 502 错误，切忌盲目瞎猜，直接使用 `tail -f /var/log/caddy/komari_access.log` 追踪日志，通过分析 HTTP 状态码和 Upstream 报错来精准定位问题。 (We specifically configured `/var/log/caddy/komari_access.log`. If a 502 error occurs, do not guess blindly; directly use `tail -f` to track the log and pinpoint the issue by analyzing HTTP status codes and Upstream errors.)&lt;br /&gt;
&lt;br /&gt;
=== 2. 重载 Caddy 生效 / Reload Caddy to Apply ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
caddy reload --config /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 第三步：多节点 Agent 接入实战 / Step 3: Multi-Node Agent Integration Practice ==&lt;br /&gt;
&lt;br /&gt;
主控端稳如泰山后，现在我们可以把其他 VPS 统一接入面板进行管理了。&lt;br /&gt;
With the controller stable as a mountain, we can now integrate your other VPS nodes into the dashboard for unified management.&lt;br /&gt;
&lt;br /&gt;
=== 1. 主控端获取连接参数 / Get Connection Parameters from Controller ===&lt;br /&gt;
登录你的 Komari 面板后台，点击“添加节点”。系统会为你生成一串专属的 Agent 连接命令，其中包含了你的 &#039;&#039;&#039;API 地址&#039;&#039;&#039; 和对应节点的 &#039;&#039;&#039;Secret Key&#039;&#039;&#039;。&lt;br /&gt;
Log into your Komari dashboard backend and click &amp;quot;Add Node&amp;quot;. The system will generate a dedicated Agent connection command containing your &#039;&#039;&#039;API Address&#039;&#039;&#039; and the corresponding node&#039;s &#039;&#039;&#039;Secret Key&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== 2. 在被控节点安装 Agent / Install Agent on the Managed Node ===&lt;br /&gt;
通过 SSH 登录到你需要监控的服务器，为了保持系统整洁，我们依然推荐使用 Docker 运行 Agent：&lt;br /&gt;
Log into the server you want to monitor via SSH. To keep the system clean, we still recommend running the Agent using Docker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker run -d \&lt;br /&gt;
  --name komari-agent \&lt;br /&gt;
  --restart unless-stopped \&lt;br /&gt;
  --net=host \&lt;br /&gt;
  -v /proc:/host/proc:ro \&lt;br /&gt;
  -v /sys:/host/sys:ro \&lt;br /&gt;
  -v /:/rootfs:ro \&lt;br /&gt;
  ghcr.io/komari-monitor/komari-agent:latest \&lt;br /&gt;
  -api &amp;quot;wss://status.yourdomain.com/api/v1/ws&amp;quot; \&lt;br /&gt;
  -secret &amp;quot;你的节点专属SecretKey&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与分析逻辑 / Debugging &amp;amp; Analysis Logic&lt;br /&gt;
: &#039;&#039;&#039;参数解析 `net=host` 与目录映射： / Parameter Parsing `net=host` and Directory Mapping:&#039;&#039;&#039; Agent 需要真实获取宿主机的网卡流量、CPU 和内存信息，因此必须使用 `--net=host` 共享网络命名空间，并将宿主机的 `/proc` 和 `/sys` 以只读 (`ro`) 模式映射进容器。 (The Agent needs to fetch real host network traffic, CPU, and memory info, so it must use `--net=host` to share the network namespace and map the host&#039;s `/proc` and `/sys` into the container in read-only (`ro`) mode.)&lt;br /&gt;
: &#039;&#039;&#039;协议检查： / Protocol Check:&#039;&#039;&#039; 确保 `-api` 参数使用的是 `wss://`（WebSocket Secure），因为我们的主控端已经配置了严格的 HTTPS。如果填成 `ws://` 将会被 Caddy 拒绝连接。 (Ensure the `-api` parameter uses `wss://` (WebSocket Secure) since our controller is configured with strict HTTPS. If filled as `ws://`, the connection will be rejected by Caddy.)&lt;br /&gt;
&lt;br /&gt;
大功告成！现在，你可以坐在屏幕前，看着所有服务器的绿色心跳线，享受数据掌控在自己手中的极致快感了。&lt;br /&gt;
Mission accomplished! Now, you can sit in front of the screen, watch the green heartbeat lines of all your servers, and enjoy the ultimate thrill of having your data under your own control.&lt;br /&gt;
&lt;br /&gt;
== 进阶探索与安全延展 / Advanced Exploration &amp;amp; Security Extension ==&lt;br /&gt;
&lt;br /&gt;
Komari 其实还有更多强大的进阶玩法等待你发掘。例如，你可以配置 Telegram Bot 接收服务器到期续费、流量预警、系统高负载以及延迟异常的实时推送（测速节点 IP 推荐在 zstaticcdn.com 获取）。此外，面板还支持高度定制化的美化主题。关于这些高级配置，篇幅所限不再展开，强烈建议访问 GitHub 搜索 `komari` 或直达官方文档 (https://komari-document.pages.dev/) 自行探索学习。&amp;lt;br&amp;gt;Komari actually has many more powerful advanced features waiting for you to discover. For instance, you can configure a Telegram Bot to receive real-time push notifications for server expiration renewals, traffic warnings, high system load, and abnormal latency (we recommend getting speed test node IPs from zstaticcdn.com). Additionally, the dashboard supports highly customizable aesthetic themes. Due to space constraints, we won&#039;t expand on these advanced configurations here. It is highly recommended to search for `komari` on GitHub or visit the official documentation (https://komari-document.pages.dev/) to explore and learn on your own.&lt;br /&gt;
&lt;br /&gt;
最后，虽然瓦工的线路极佳，但公网环境险恶。为了预防潜在的 DDoS 攻击或端口嗅探，你可以进一步研究如何为面板或网站套上“赛博菩萨” Cloudflare 的 Proxy (CDN) 甚至配置更为安全的 Cloudflare Tunnel。这些都是 VPS 玩家进阶的必修课，期待你查阅相关资料，继续点亮你的网络安全技能树！&amp;lt;br&amp;gt;Finally, although BandwagonHost&#039;s routing is excellent, the public internet environment is perilous. To prevent potential DDoS attacks or port sniffing, you can further research how to put your dashboard or website behind the &amp;quot;Cyber Bodhisattva&amp;quot; Cloudflare&#039;s Proxy (CDN) or even configure the much safer Cloudflare Tunnel. These are required courses for advanced VPS players. We look forward to you looking up relevant materials and continuing to light up your network security skill tree!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;Created by AlexLynn for md5.pw Community.&#039;&#039;&lt;br /&gt;
[[Category:500 常见应用指南 — Application Guides]]&lt;/div&gt;</summary>
		<author><name>AlexLynn</name></author>
	</entry>
	<entry>
		<id>https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1484</id>
		<title>搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术</title>
		<link rel="alternate" type="text/html" href="https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1484"/>
		<updated>2026-03-01T06:09:58Z</updated>

		<summary type="html">&lt;p&gt;AlexLynn：​重定向页面至BWH CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[BWH CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术]]&lt;/div&gt;</summary>
		<author><name>AlexLynn</name></author>
	</entry>
	<entry>
		<id>https://md5.pw/index.php?title=BWH_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1483</id>
		<title>BWH CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术</title>
		<link rel="alternate" type="text/html" href="https://md5.pw/index.php?title=BWH_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1483"/>
		<updated>2026-03-01T06:08:47Z</updated>

		<summary type="html">&lt;p&gt;AlexLynn：​创建页面，内容为“= 搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术 = = BandwagonHost CN2 GIA &amp;amp; Komari: A Lightweight Go Probe Presenting the Art of Top-Tier Networking =  搬瓦工（BandwagonHost）的 CN2 GIA 线路堪称 VPS 界的网络天花板。其三网顶级直连架构不仅带来了令人惊叹的极致超低延迟，更是在晚高峰也能保持全天候 &amp;#039;&amp;#039;&amp;#039;0 丢包&amp;#039;&amp;#039;&amp;#039; 的神话。这种丝滑、纯粹的网络体验，如果…”&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术 =&lt;br /&gt;
= BandwagonHost CN2 GIA &amp;amp; Komari: A Lightweight Go Probe Presenting the Art of Top-Tier Networking =&lt;br /&gt;
&lt;br /&gt;
搬瓦工（BandwagonHost）的 CN2 GIA 线路堪称 VPS 界的网络天花板。其三网顶级直连架构不仅带来了令人惊叹的极致超低延迟，更是在晚高峰也能保持全天候 &#039;&#039;&#039;0 丢包&#039;&#039;&#039; 的神话。这种丝滑、纯粹的网络体验，如果不配上一个优秀的现代监控探针将其彻底可视化，简直是暴殄天物！&lt;br /&gt;
BandwagonHost&#039;s CN2 GIA routing is arguably the network ceiling of the VPS world. Its top-tier direct connection across all three major networks brings not only amazingly stable and low latency but also maintains a mythical &#039;&#039;&#039;0 packet loss&#039;&#039;&#039; even during peak hours. Such a silky-smooth and pure network experience would be an absolute waste if not thoroughly visualized with an excellent modern monitoring dashboard!&lt;br /&gt;
&lt;br /&gt;
为了不辜负瓦工如此顶级的线路，我们需要一款同样极致的探针。今天的主角 &#039;&#039;&#039;Komari&#039;&#039;&#039; 正是为此而生。&lt;br /&gt;
To live up to such top-tier routing from BandwagonHost, we need an equally ultimate probe. Today&#039;s protagonist, &#039;&#039;&#039;Komari&#039;&#039;&#039;, was born for this exact purpose.&lt;br /&gt;
&lt;br /&gt;
== 为什么选择 Komari？ / Why Choose Komari? ==&lt;br /&gt;
&lt;br /&gt;
[[File:Komari.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
市面上的服务器监控面板琳琅满目，但 Komari 凭借其独特的架构脱颖而出：&lt;br /&gt;
The market is full of server monitoring panels, but Komari stands out with its unique architecture:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;基于 Go 语言构建 / Built with Go&#039;&#039;&#039;：Komari 的主控端和 Agent 均采用 Golang 编写。天生的高并发优势和出色的内存管理，使得它能以极低的系统资源占用，轻松处理并发连接。&amp;lt;br&amp;gt;Komari&#039;s controller and agent are both written in Golang. Its inherent high-concurrency advantages and excellent memory management allow it to easily handle concurrent connections with extremely low system resource consumption.&lt;br /&gt;
* &#039;&#039;&#039;优雅的 Controller + Agent 架构 / Elegant Controller + Agent Architecture&#039;&#039;&#039;：主控面板（Controller）负责节点管理与数据展示，轻量 Agent 负责采集系统指标，并通过 WebSocket 持久连接上报数据。这种设计避免了传统轮询式监控产生的大量请求开销，在低带宽 VPS 环境下依然能够保持高实时性与极低资源占用。&amp;lt;br&amp;gt;The controller dashboard is responsible for node management and data presentation, while the lightweight Agent collects system metrics and reports data via persistent WebSocket connections. This design avoids the massive request overhead generated by traditional polling-based monitoring, maintaining high real-time performance and extremely low resource usage even in low-bandwidth VPS environments.&lt;br /&gt;
* &#039;&#039;&#039;极致轻量与极简主义 / Extreme Lightweight &amp;amp; Minimalism&#039;&#039;&#039;：监控工具本身不应成为服务器的负担。Komari 没有臃肿的依赖库，对于极其珍贵的瓦工服务器资源来说，运行它几乎是“零感知”的。&amp;lt;br&amp;gt;Monitoring tools themselves shouldn&#039;t be a burden on the server. Komari has no bloated dependency libraries; for the extremely precious BandwagonHost server resources, running it is almost &amp;quot;zero-perception&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
本文将通过严谨的逻辑，一步一步完成 Komari 的基础部署、高级安全反代，以及多节点 Agent 的接入。&lt;br /&gt;
This article will walk through the basic deployment of Komari, advanced secure reverse proxy configuration, and multi-node Agent integration, step-by-step with rigorous logic.&lt;br /&gt;
&lt;br /&gt;
== 第一步：基础安装 - 部署 Komari 主控 / Step 1: Basic Installation - Deploying Komari Controller ==&lt;br /&gt;
&lt;br /&gt;
无论你是在白天使用 Windows 办公，还是使用 macOS 的终端，请先通过 SSH 接入你的搬瓦工服务器。为了保证环境的隔离性和未来排错的便利性，我们采用 Docker Compose 进行部署。&lt;br /&gt;
Whether you are working on Windows during the day or using the macOS terminal, please SSH into your BandwagonHost server first. To ensure environmental isolation and ease of future troubleshooting, we will deploy using Docker Compose.&lt;br /&gt;
&lt;br /&gt;
=== 1. 创建项目目录结构 / Create Project Directory Structure ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /opt/komari &amp;amp;&amp;amp; cd /opt/komari&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. 编写 Docker Compose 配置文件 / Write the Docker Compose Configuration ===&lt;br /&gt;
创建并编辑 Docker Compose 配置文件：&lt;br /&gt;
Create and edit the Docker Compose configuration file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano docker-compose.yml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下内容（注意端口映射的安全加固与版本控制）：&lt;br /&gt;
Write the following content (note the security hardening of port mapping and version control):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
version: &#039;3.8&#039;&lt;br /&gt;
services:&lt;br /&gt;
  komari:&lt;br /&gt;
    # 生产环境建议将 latest 替换为具体的 release 版本号以保证系统稳定性&lt;br /&gt;
    # For production, it&#039;s recommended to replace &#039;latest&#039; with a specific release version to ensure system stability&lt;br /&gt;
    image: ghcr.io/komari-monitor/komari:latest&lt;br /&gt;
    container_name: komari&lt;br /&gt;
    restart: unless-stopped&lt;br /&gt;
    ports:&lt;br /&gt;
      - &amp;quot;127.0.0.1:25774:25774&amp;quot;&lt;br /&gt;
    volumes:&lt;br /&gt;
      - ./data:/app/data&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与安全分析逻辑 / Debugging &amp;amp; Security Analysis Logic&lt;br /&gt;
: &#039;&#039;&#039;为什么映射 `/app/data`？ / Why map `/app/data`?&#039;&#039;&#039; 探针的面板设置、节点信息都物理存储在这个目录。如果不做映射，一旦容器重启或销毁，所有配置数据将全部丢失。 (The panel settings and node information are physically stored in this directory. If not mapped, all configuration data will be completely lost once the container restarts or is destroyed.)&lt;br /&gt;
: &#039;&#039;&#039;安全加固 `127.0.0.1`： / Security Hardening `127.0.0.1`:&#039;&#039;&#039; 绑定本地环回地址 `127.0.0.1`，杜绝被批量扫描及 0day 漏洞攻击的潜在威胁。 (Binding to the local loopback address `127.0.0.1` eliminates the potential threat of being bulk-scanned and attacked by 0-day vulnerabilities.)&lt;br /&gt;
&lt;br /&gt;
=== 3. 启动服务 / Start the Service ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker compose up -d&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
启动后，执行 `docker logs komari` 查看系统自动生成的初始管理员账号和密码。&lt;br /&gt;
After starting, execute `docker logs komari` to view the initial admin account and password automatically generated by the system.&lt;br /&gt;
&lt;br /&gt;
== 第二步：进阶配置 - Caddy 详尽反代与 HTTPS / Step 2: Advanced Configuration - Detailed Caddy Reverse Proxy &amp;amp; HTTPS ==&lt;br /&gt;
&lt;br /&gt;
在前端，我们将使用 Caddy 申请免费证书并进行反向代理，将安全的 HTTPS 流量转发给内网的 Komari。&lt;br /&gt;
On the frontend, we will use Caddy to request a free certificate and set up a reverse proxy to forward secure HTTPS traffic to the internal Komari service.&lt;br /&gt;
&lt;br /&gt;
=== 1. 编辑 Caddyfile / Edit the Caddyfile ===&lt;br /&gt;
打开你的 Caddy 配置文件（通常位于 `/etc/caddy/Caddyfile`）：&lt;br /&gt;
Open your Caddy config file (usually located at `/etc/caddy/Caddyfile`):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下配置（请将 `status.yourdomain.com` 替换为你的真实域名）：&lt;br /&gt;
Write the following configuration (please replace `status.yourdomain.com` with your real domain name):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
status.yourdomain.com {&lt;br /&gt;
    # 启用现代 TLS 协议 / Enable modern TLS protocols&lt;br /&gt;
    tls {&lt;br /&gt;
        protocols tls1.2 tls1.3&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 反向代理至本地环回地址的 Komari 端口 / Reverse proxy to the Komari port on the local loopback address&lt;br /&gt;
    reverse_proxy localhost:25774 {&lt;br /&gt;
        # 传递真实访客 IP 和协议 / Pass real visitor IP and protocol&lt;br /&gt;
        header_up Host {host}&lt;br /&gt;
        header_up X-Real-IP {remote}&lt;br /&gt;
        header_up X-Forwarded-For {remote}&lt;br /&gt;
        header_up X-Forwarded-Proto {scheme}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    # 启用压缩机制以加快探针面板加载速度 / Enable compression to speed up dashboard loading&lt;br /&gt;
    encode gzip zstd&lt;br /&gt;
&lt;br /&gt;
    # 现代且严谨的安全响应头设置 / Modern and rigorous security response headers setup&lt;br /&gt;
    header {&lt;br /&gt;
        # 注意：此处未加 preload，只有在你准备将域名提交到浏览器 HSTS preload list 时才建议加入 preload 参数&lt;br /&gt;
        # Note: &#039;preload&#039; is omitted here; it is only recommended if you plan to submit the domain to the browser HSTS preload list&lt;br /&gt;
        Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        X-Content-Type-Options &amp;quot;nosniff&amp;quot;&lt;br /&gt;
        X-Frame-Options &amp;quot;SAMEORIGIN&amp;quot;&lt;br /&gt;
        Referrer-Policy &amp;quot;strict-origin-when-cross-origin&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 详尽的访问日志记录，为未来排错提供明确的数据分析支持 / Detailed access logging to provide clear data support for future debugging&lt;br /&gt;
    log {&lt;br /&gt;
        output file /var/log/caddy/komari_access.log {&lt;br /&gt;
            roll_size 100mb&lt;br /&gt;
            roll_keep 5&lt;br /&gt;
        }&lt;br /&gt;
        format json&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与排错逻辑 / Debugging &amp;amp; Troubleshooting Logic&lt;br /&gt;
: &#039;&#039;&#039;WebSocket 断连与 Cloudflare 避坑： / WebSocket Disconnection &amp;amp; Cloudflare Pitfalls:&#039;&#039;&#039; Komari 极其依赖 WebSocket 进行实时数据推送（Caddy v2 默认原生支持 WebSocket 转发）。如果你发现面板卡死不刷新，请首先检查链路。如果你在前端套用了 Cloudflare，请务必检查：1. 网络设置中的 &amp;quot;WebSockets&amp;quot; 选项是否开启；2. SSL/TLS 加密模式必须设置为 &amp;quot;Full&amp;quot; 或 &amp;quot;Full (Strict)&amp;quot;，否则会导致循环重定向或握手失败。 (Komari heavily relies on WebSocket for real-time data push. If the panel freezes, check the link first. If using Cloudflare, ensure: 1. &amp;quot;WebSockets&amp;quot; is enabled in Network settings; 2. SSL/TLS mode is set to &amp;quot;Full&amp;quot; or &amp;quot;Full (Strict)&amp;quot; to prevent redirect loops or handshake failures.)&lt;br /&gt;
: &#039;&#039;&#039;日志分析排错： / Log Analysis Troubleshooting:&#039;&#039;&#039; 这里专门配置了 `/var/log/caddy/komari_access.log`。如果配置完出现 502 错误，切忌盲目瞎猜，直接使用 `tail -f /var/log/caddy/komari_access.log` 追踪日志，通过分析 HTTP 状态码和 Upstream 报错来精准定位问题。 (We specifically configured `/var/log/caddy/komari_access.log`. If a 502 error occurs, do not guess blindly; directly use `tail -f` to track the log and pinpoint the issue by analyzing HTTP status codes and Upstream errors.)&lt;br /&gt;
&lt;br /&gt;
=== 2. 重载 Caddy 生效 / Reload Caddy to Apply ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
caddy reload --config /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 第三步：多节点 Agent 接入实战 / Step 3: Multi-Node Agent Integration Practice ==&lt;br /&gt;
&lt;br /&gt;
主控端稳如泰山后，现在我们可以把其他 VPS 统一接入面板进行管理了。&lt;br /&gt;
With the controller stable as a mountain, we can now integrate your other VPS nodes into the dashboard for unified management.&lt;br /&gt;
&lt;br /&gt;
=== 1. 主控端获取连接参数 / Get Connection Parameters from Controller ===&lt;br /&gt;
登录你的 Komari 面板后台，点击“添加节点”。系统会为你生成一串专属的 Agent 连接命令，其中包含了你的 &#039;&#039;&#039;API 地址&#039;&#039;&#039; 和对应节点的 &#039;&#039;&#039;Secret Key&#039;&#039;&#039;。&lt;br /&gt;
Log into your Komari dashboard backend and click &amp;quot;Add Node&amp;quot;. The system will generate a dedicated Agent connection command containing your &#039;&#039;&#039;API Address&#039;&#039;&#039; and the corresponding node&#039;s &#039;&#039;&#039;Secret Key&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== 2. 在被控节点安装 Agent / Install Agent on the Managed Node ===&lt;br /&gt;
通过 SSH 登录到你需要监控的服务器，为了保持系统整洁，我们依然推荐使用 Docker 运行 Agent：&lt;br /&gt;
Log into the server you want to monitor via SSH. To keep the system clean, we still recommend running the Agent using Docker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker run -d \&lt;br /&gt;
  --name komari-agent \&lt;br /&gt;
  --restart unless-stopped \&lt;br /&gt;
  --net=host \&lt;br /&gt;
  -v /proc:/host/proc:ro \&lt;br /&gt;
  -v /sys:/host/sys:ro \&lt;br /&gt;
  -v /:/rootfs:ro \&lt;br /&gt;
  ghcr.io/komari-monitor/komari-agent:latest \&lt;br /&gt;
  -api &amp;quot;wss://status.yourdomain.com/api/v1/ws&amp;quot; \&lt;br /&gt;
  -secret &amp;quot;你的节点专属SecretKey&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与分析逻辑 / Debugging &amp;amp; Analysis Logic&lt;br /&gt;
: &#039;&#039;&#039;参数解析 `net=host` 与目录映射： / Parameter Parsing `net=host` and Directory Mapping:&#039;&#039;&#039; Agent 需要真实获取宿主机的网卡流量、CPU 和内存信息，因此必须使用 `--net=host` 共享网络命名空间，并将宿主机的 `/proc` 和 `/sys` 以只读 (`ro`) 模式映射进容器。 (The Agent needs to fetch real host network traffic, CPU, and memory info, so it must use `--net=host` to share the network namespace and map the host&#039;s `/proc` and `/sys` into the container in read-only (`ro`) mode.)&lt;br /&gt;
: &#039;&#039;&#039;协议检查： / Protocol Check:&#039;&#039;&#039; 确保 `-api` 参数使用的是 `wss://`（WebSocket Secure），因为我们的主控端已经配置了严格的 HTTPS。如果填成 `ws://` 将会被 Caddy 拒绝连接。 (Ensure the `-api` parameter uses `wss://` (WebSocket Secure) since our controller is configured with strict HTTPS. If filled as `ws://`, the connection will be rejected by Caddy.)&lt;br /&gt;
&lt;br /&gt;
大功告成！现在，你可以坐在屏幕前，看着所有服务器的绿色心跳线，享受数据掌控在自己手中的极致快感了。&lt;br /&gt;
Mission accomplished! Now, you can sit in front of the screen, watch the green heartbeat lines of all your servers, and enjoy the ultimate thrill of having your data under your own control.&lt;br /&gt;
&lt;br /&gt;
== 进阶探索与安全延展 / Advanced Exploration &amp;amp; Security Extension ==&lt;br /&gt;
&lt;br /&gt;
Komari 其实还有更多强大的进阶玩法等待你发掘。例如，你可以配置 Telegram Bot 接收服务器到期续费、流量预警、系统高负载以及延迟异常的实时推送（测速节点 IP 推荐在 zstaticcdn.com 获取）。此外，面板还支持高度定制化的美化主题。关于这些高级配置，篇幅所限不再展开，强烈建议访问 GitHub 搜索 `komari` 或直达官方文档 (https://komari-document.pages.dev/) 自行探索学习。&amp;lt;br&amp;gt;Komari actually has many more powerful advanced features waiting for you to discover. For instance, you can configure a Telegram Bot to receive real-time push notifications for server expiration renewals, traffic warnings, high system load, and abnormal latency (we recommend getting speed test node IPs from zstaticcdn.com). Additionally, the dashboard supports highly customizable aesthetic themes. Due to space constraints, we won&#039;t expand on these advanced configurations here. It is highly recommended to search for `komari` on GitHub or visit the official documentation (https://komari-document.pages.dev/) to explore and learn on your own.&lt;br /&gt;
&lt;br /&gt;
最后，虽然瓦工的线路极佳，但公网环境险恶。为了预防潜在的 DDoS 攻击或端口嗅探，你可以进一步研究如何为面板或网站套上“赛博菩萨” Cloudflare 的 Proxy (CDN) 甚至配置更为安全的 Cloudflare Tunnel。这些都是 VPS 玩家进阶的必修课，期待你查阅相关资料，继续点亮你的网络安全技能树！&amp;lt;br&amp;gt;Finally, although BandwagonHost&#039;s routing is excellent, the public internet environment is perilous. To prevent potential DDoS attacks or port sniffing, you can further research how to put your dashboard or website behind the &amp;quot;Cyber Bodhisattva&amp;quot; Cloudflare&#039;s Proxy (CDN) or even configure the much safer Cloudflare Tunnel. These are required courses for advanced VPS players. We look forward to you looking up relevant materials and continuing to light up your network security skill tree!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;Created by AlexLynn for md5.pw Community.&#039;&#039;&lt;br /&gt;
[[index.php?title=Category:500 常见应用指南 — Application Guides]]&lt;/div&gt;</summary>
		<author><name>AlexLynn</name></author>
	</entry>
	<entry>
		<id>https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1482</id>
		<title>搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术</title>
		<link rel="alternate" type="text/html" href="https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1482"/>
		<updated>2026-03-01T06:02:48Z</updated>

		<summary type="html">&lt;p&gt;AlexLynn：​&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术 =&lt;br /&gt;
= BandwagonHost CN2 GIA &amp;amp; Komari: A Lightweight Go Probe Presenting the Art of Top-Tier Networking =&lt;br /&gt;
&lt;br /&gt;
搬瓦工（BandwagonHost）的 CN2 GIA 线路堪称 VPS 界的网络天花板。其三网顶级直连架构不仅带来了令人惊叹的极致超低延迟，更是在晚高峰也能保持全天候 &#039;&#039;&#039;0 丢包&#039;&#039;&#039; 的神话。这种丝滑、纯粹的网络体验，如果不配上一个优秀的现代监控探针将其彻底可视化，简直是暴殄天物！&lt;br /&gt;
BandwagonHost&#039;s CN2 GIA routing is arguably the network ceiling of the VPS world. Its top-tier direct connection across all three major networks brings not only amazingly stable and low latency but also maintains a mythical &#039;&#039;&#039;0 packet loss&#039;&#039;&#039; even during peak hours. Such a silky-smooth and pure network experience would be an absolute waste if not thoroughly visualized with an excellent modern monitoring dashboard!&lt;br /&gt;
&lt;br /&gt;
为了不辜负瓦工如此顶级的线路，我们需要一款同样极致的探针。今天的主角 &#039;&#039;&#039;Komari&#039;&#039;&#039; 正是为此而生。&lt;br /&gt;
To live up to such top-tier routing from BandwagonHost, we need an equally ultimate probe. Today&#039;s protagonist, &#039;&#039;&#039;Komari&#039;&#039;&#039;, was born for this exact purpose.&lt;br /&gt;
&lt;br /&gt;
== 为什么选择 Komari？ / Why Choose Komari? ==&lt;br /&gt;
&lt;br /&gt;
[[File:Komari.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
市面上的服务器监控面板琳琅满目，但 Komari 凭借其独特的架构脱颖而出：&lt;br /&gt;
The market is full of server monitoring panels, but Komari stands out with its unique architecture:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;基于 Go 语言构建 / Built with Go&#039;&#039;&#039;：Komari 的主控端和 Agent 均采用 Golang 编写。天生的高并发优势和出色的内存管理，使得它能以极低的系统资源占用，轻松处理并发连接。&amp;lt;br&amp;gt;Komari&#039;s controller and agent are both written in Golang. Its inherent high-concurrency advantages and excellent memory management allow it to easily handle concurrent connections with extremely low system resource consumption.&lt;br /&gt;
* &#039;&#039;&#039;优雅的 Controller + Agent 架构 / Elegant Controller + Agent Architecture&#039;&#039;&#039;：主控面板（Controller）负责节点管理与数据展示，轻量 Agent 负责采集系统指标，并通过 WebSocket 持久连接上报数据。这种设计避免了传统轮询式监控产生的大量请求开销，在低带宽 VPS 环境下依然能够保持高实时性与极低资源占用。&amp;lt;br&amp;gt;The controller dashboard is responsible for node management and data presentation, while the lightweight Agent collects system metrics and reports data via persistent WebSocket connections. This design avoids the massive request overhead generated by traditional polling-based monitoring, maintaining high real-time performance and extremely low resource usage even in low-bandwidth VPS environments.&lt;br /&gt;
* &#039;&#039;&#039;极致轻量与极简主义 / Extreme Lightweight &amp;amp; Minimalism&#039;&#039;&#039;：监控工具本身不应成为服务器的负担。Komari 没有臃肿的依赖库，对于极其珍贵的瓦工服务器资源来说，运行它几乎是“零感知”的。&amp;lt;br&amp;gt;Monitoring tools themselves shouldn&#039;t be a burden on the server. Komari has no bloated dependency libraries; for the extremely precious BandwagonHost server resources, running it is almost &amp;quot;zero-perception&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
本文将通过严谨的逻辑，一步一步完成 Komari 的基础部署、高级安全反代，以及多节点 Agent 的接入。&lt;br /&gt;
This article will walk through the basic deployment of Komari, advanced secure reverse proxy configuration, and multi-node Agent integration, step-by-step with rigorous logic.&lt;br /&gt;
&lt;br /&gt;
== 第一步：基础安装 - 部署 Komari 主控 / Step 1: Basic Installation - Deploying Komari Controller ==&lt;br /&gt;
&lt;br /&gt;
无论你是在白天使用 Windows 办公，还是使用 macOS 的终端，请先通过 SSH 接入你的搬瓦工服务器。为了保证环境的隔离性和未来排错的便利性，我们采用 Docker Compose 进行部署。&lt;br /&gt;
Whether you are working on Windows during the day or using the macOS terminal, please SSH into your BandwagonHost server first. To ensure environmental isolation and ease of future troubleshooting, we will deploy using Docker Compose.&lt;br /&gt;
&lt;br /&gt;
=== 1. 创建项目目录结构 / Create Project Directory Structure ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /opt/komari &amp;amp;&amp;amp; cd /opt/komari&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. 编写 Docker Compose 配置文件 / Write the Docker Compose Configuration ===&lt;br /&gt;
创建并编辑 Docker Compose 配置文件：&lt;br /&gt;
Create and edit the Docker Compose configuration file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano docker-compose.yml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下内容（注意端口映射的安全加固与版本控制）：&lt;br /&gt;
Write the following content (note the security hardening of port mapping and version control):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
version: &#039;3.8&#039;&lt;br /&gt;
services:&lt;br /&gt;
  komari:&lt;br /&gt;
    # 生产环境建议将 latest 替换为具体的 release 版本号以保证系统稳定性&lt;br /&gt;
    # For production, it&#039;s recommended to replace &#039;latest&#039; with a specific release version to ensure system stability&lt;br /&gt;
    image: ghcr.io/komari-monitor/komari:latest&lt;br /&gt;
    container_name: komari&lt;br /&gt;
    restart: unless-stopped&lt;br /&gt;
    ports:&lt;br /&gt;
      - &amp;quot;127.0.0.1:25774:25774&amp;quot;&lt;br /&gt;
    volumes:&lt;br /&gt;
      - ./data:/app/data&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与安全分析逻辑 / Debugging &amp;amp; Security Analysis Logic&lt;br /&gt;
: &#039;&#039;&#039;为什么映射 `/app/data`？ / Why map `/app/data`?&#039;&#039;&#039; 探针的面板设置、节点信息都物理存储在这个目录。如果不做映射，一旦容器重启或销毁，所有配置数据将全部丢失。 (The panel settings and node information are physically stored in this directory. If not mapped, all configuration data will be completely lost once the container restarts or is destroyed.)&lt;br /&gt;
: &#039;&#039;&#039;安全加固 `127.0.0.1`： / Security Hardening `127.0.0.1`:&#039;&#039;&#039; 绑定本地环回地址 `127.0.0.1`，杜绝被批量扫描及 0day 漏洞攻击的潜在威胁。 (Binding to the local loopback address `127.0.0.1` eliminates the potential threat of being bulk-scanned and attacked by 0-day vulnerabilities.)&lt;br /&gt;
&lt;br /&gt;
=== 3. 启动服务 / Start the Service ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker compose up -d&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
启动后，执行 `docker logs komari` 查看系统自动生成的初始管理员账号和密码。&lt;br /&gt;
After starting, execute `docker logs komari` to view the initial admin account and password automatically generated by the system.&lt;br /&gt;
&lt;br /&gt;
== 第二步：进阶配置 - Caddy 详尽反代与 HTTPS / Step 2: Advanced Configuration - Detailed Caddy Reverse Proxy &amp;amp; HTTPS ==&lt;br /&gt;
&lt;br /&gt;
在前端，我们将使用 Caddy 申请免费证书并进行反向代理，将安全的 HTTPS 流量转发给内网的 Komari。&lt;br /&gt;
On the frontend, we will use Caddy to request a free certificate and set up a reverse proxy to forward secure HTTPS traffic to the internal Komari service.&lt;br /&gt;
&lt;br /&gt;
=== 1. 编辑 Caddyfile / Edit the Caddyfile ===&lt;br /&gt;
打开你的 Caddy 配置文件（通常位于 `/etc/caddy/Caddyfile`）：&lt;br /&gt;
Open your Caddy config file (usually located at `/etc/caddy/Caddyfile`):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下配置（请将 `status.yourdomain.com` 替换为你的真实域名）：&lt;br /&gt;
Write the following configuration (please replace `status.yourdomain.com` with your real domain name):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
status.yourdomain.com {&lt;br /&gt;
    # 启用现代 TLS 协议 / Enable modern TLS protocols&lt;br /&gt;
    tls {&lt;br /&gt;
        protocols tls1.2 tls1.3&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 反向代理至本地环回地址的 Komari 端口 / Reverse proxy to the Komari port on the local loopback address&lt;br /&gt;
    reverse_proxy localhost:25774 {&lt;br /&gt;
        # 传递真实访客 IP 和协议 / Pass real visitor IP and protocol&lt;br /&gt;
        header_up Host {host}&lt;br /&gt;
        header_up X-Real-IP {remote}&lt;br /&gt;
        header_up X-Forwarded-For {remote}&lt;br /&gt;
        header_up X-Forwarded-Proto {scheme}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    # 启用压缩机制以加快探针面板加载速度 / Enable compression to speed up dashboard loading&lt;br /&gt;
    encode gzip zstd&lt;br /&gt;
&lt;br /&gt;
    # 现代且严谨的安全响应头设置 / Modern and rigorous security response headers setup&lt;br /&gt;
    header {&lt;br /&gt;
        # 注意：此处未加 preload，只有在你准备将域名提交到浏览器 HSTS preload list 时才建议加入 preload 参数&lt;br /&gt;
        # Note: &#039;preload&#039; is omitted here; it is only recommended if you plan to submit the domain to the browser HSTS preload list&lt;br /&gt;
        Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        X-Content-Type-Options &amp;quot;nosniff&amp;quot;&lt;br /&gt;
        X-Frame-Options &amp;quot;SAMEORIGIN&amp;quot;&lt;br /&gt;
        Referrer-Policy &amp;quot;strict-origin-when-cross-origin&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 详尽的访问日志记录，为未来排错提供明确的数据分析支持 / Detailed access logging to provide clear data support for future debugging&lt;br /&gt;
    log {&lt;br /&gt;
        output file /var/log/caddy/komari_access.log {&lt;br /&gt;
            roll_size 100mb&lt;br /&gt;
            roll_keep 5&lt;br /&gt;
        }&lt;br /&gt;
        format json&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与排错逻辑 / Debugging &amp;amp; Troubleshooting Logic&lt;br /&gt;
: &#039;&#039;&#039;WebSocket 断连与 Cloudflare 避坑： / WebSocket Disconnection &amp;amp; Cloudflare Pitfalls:&#039;&#039;&#039; Komari 极其依赖 WebSocket 进行实时数据推送（Caddy v2 默认原生支持 WebSocket 转发）。如果你发现面板卡死不刷新，请首先检查链路。如果你在前端套用了 Cloudflare，请务必检查：1. 网络设置中的 &amp;quot;WebSockets&amp;quot; 选项是否开启；2. SSL/TLS 加密模式必须设置为 &amp;quot;Full&amp;quot; 或 &amp;quot;Full (Strict)&amp;quot;，否则会导致循环重定向或握手失败。 (Komari heavily relies on WebSocket for real-time data push. If the panel freezes, check the link first. If using Cloudflare, ensure: 1. &amp;quot;WebSockets&amp;quot; is enabled in Network settings; 2. SSL/TLS mode is set to &amp;quot;Full&amp;quot; or &amp;quot;Full (Strict)&amp;quot; to prevent redirect loops or handshake failures.)&lt;br /&gt;
: &#039;&#039;&#039;日志分析排错： / Log Analysis Troubleshooting:&#039;&#039;&#039; 这里专门配置了 `/var/log/caddy/komari_access.log`。如果配置完出现 502 错误，切忌盲目瞎猜，直接使用 `tail -f /var/log/caddy/komari_access.log` 追踪日志，通过分析 HTTP 状态码和 Upstream 报错来精准定位问题。 (We specifically configured `/var/log/caddy/komari_access.log`. If a 502 error occurs, do not guess blindly; directly use `tail -f` to track the log and pinpoint the issue by analyzing HTTP status codes and Upstream errors.)&lt;br /&gt;
&lt;br /&gt;
=== 2. 重载 Caddy 生效 / Reload Caddy to Apply ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
caddy reload --config /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 第三步：多节点 Agent 接入实战 / Step 3: Multi-Node Agent Integration Practice ==&lt;br /&gt;
&lt;br /&gt;
主控端稳如泰山后，现在我们可以把其他 VPS 统一接入面板进行管理了。&lt;br /&gt;
With the controller stable as a mountain, we can now integrate your other VPS nodes into the dashboard for unified management.&lt;br /&gt;
&lt;br /&gt;
=== 1. 主控端获取连接参数 / Get Connection Parameters from Controller ===&lt;br /&gt;
登录你的 Komari 面板后台，点击“添加节点”。系统会为你生成一串专属的 Agent 连接命令，其中包含了你的 &#039;&#039;&#039;API 地址&#039;&#039;&#039; 和对应节点的 &#039;&#039;&#039;Secret Key&#039;&#039;&#039;。&lt;br /&gt;
Log into your Komari dashboard backend and click &amp;quot;Add Node&amp;quot;. The system will generate a dedicated Agent connection command containing your &#039;&#039;&#039;API Address&#039;&#039;&#039; and the corresponding node&#039;s &#039;&#039;&#039;Secret Key&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== 2. 在被控节点安装 Agent / Install Agent on the Managed Node ===&lt;br /&gt;
通过 SSH 登录到你需要监控的服务器，为了保持系统整洁，我们依然推荐使用 Docker 运行 Agent：&lt;br /&gt;
Log into the server you want to monitor via SSH. To keep the system clean, we still recommend running the Agent using Docker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker run -d \&lt;br /&gt;
  --name komari-agent \&lt;br /&gt;
  --restart unless-stopped \&lt;br /&gt;
  --net=host \&lt;br /&gt;
  -v /proc:/host/proc:ro \&lt;br /&gt;
  -v /sys:/host/sys:ro \&lt;br /&gt;
  -v /:/rootfs:ro \&lt;br /&gt;
  ghcr.io/komari-monitor/komari-agent:latest \&lt;br /&gt;
  -api &amp;quot;wss://status.yourdomain.com/api/v1/ws&amp;quot; \&lt;br /&gt;
  -secret &amp;quot;你的节点专属SecretKey&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与分析逻辑 / Debugging &amp;amp; Analysis Logic&lt;br /&gt;
: &#039;&#039;&#039;参数解析 `net=host` 与目录映射： / Parameter Parsing `net=host` and Directory Mapping:&#039;&#039;&#039; Agent 需要真实获取宿主机的网卡流量、CPU 和内存信息，因此必须使用 `--net=host` 共享网络命名空间，并将宿主机的 `/proc` 和 `/sys` 以只读 (`ro`) 模式映射进容器。 (The Agent needs to fetch real host network traffic, CPU, and memory info, so it must use `--net=host` to share the network namespace and map the host&#039;s `/proc` and `/sys` into the container in read-only (`ro`) mode.)&lt;br /&gt;
: &#039;&#039;&#039;协议检查： / Protocol Check:&#039;&#039;&#039; 确保 `-api` 参数使用的是 `wss://`（WebSocket Secure），因为我们的主控端已经配置了严格的 HTTPS。如果填成 `ws://` 将会被 Caddy 拒绝连接。 (Ensure the `-api` parameter uses `wss://` (WebSocket Secure) since our controller is configured with strict HTTPS. If filled as `ws://`, the connection will be rejected by Caddy.)&lt;br /&gt;
&lt;br /&gt;
大功告成！现在，你可以坐在屏幕前，看着所有服务器的绿色心跳线，享受数据掌控在自己手中的极致快感了。&lt;br /&gt;
Mission accomplished! Now, you can sit in front of the screen, watch the green heartbeat lines of all your servers, and enjoy the ultimate thrill of having your data under your own control.&lt;br /&gt;
&lt;br /&gt;
== 进阶探索与安全延展 / Advanced Exploration &amp;amp; Security Extension ==&lt;br /&gt;
&lt;br /&gt;
Komari 其实还有更多强大的进阶玩法等待你发掘。例如，你可以配置 Telegram Bot 接收服务器到期续费、流量预警、系统高负载以及延迟异常的实时推送（测速节点 IP 推荐在 zstaticcdn.com 获取）。此外，面板还支持高度定制化的美化主题。关于这些高级配置，篇幅所限不再展开，强烈建议访问 GitHub 搜索 `komari` 或直达官方文档 (https://komari-document.pages.dev/) 自行探索学习。&amp;lt;br&amp;gt;Komari actually has many more powerful advanced features waiting for you to discover. For instance, you can configure a Telegram Bot to receive real-time push notifications for server expiration renewals, traffic warnings, high system load, and abnormal latency (we recommend getting speed test node IPs from zstaticcdn.com). Additionally, the dashboard supports highly customizable aesthetic themes. Due to space constraints, we won&#039;t expand on these advanced configurations here. It is highly recommended to search for `komari` on GitHub or visit the official documentation (https://komari-document.pages.dev/) to explore and learn on your own.&lt;br /&gt;
&lt;br /&gt;
最后，虽然瓦工的线路极佳，但公网环境险恶。为了预防潜在的 DDoS 攻击或端口嗅探，你可以进一步研究如何为面板或网站套上“赛博菩萨” Cloudflare 的 Proxy (CDN) 甚至配置更为安全的 Cloudflare Tunnel。这些都是 VPS 玩家进阶的必修课，期待你查阅相关资料，继续点亮你的网络安全技能树！&amp;lt;br&amp;gt;Finally, although BandwagonHost&#039;s routing is excellent, the public internet environment is perilous. To prevent potential DDoS attacks or port sniffing, you can further research how to put your dashboard or website behind the &amp;quot;Cyber Bodhisattva&amp;quot; Cloudflare&#039;s Proxy (CDN) or even configure the much safer Cloudflare Tunnel. These are required courses for advanced VPS players. We look forward to you looking up relevant materials and continuing to light up your network security skill tree!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;Created by AlexLynn for md5.pw Community.&#039;&#039;&lt;br /&gt;
[[Category:500 常见应用指南 — Application Guides]]&lt;/div&gt;</summary>
		<author><name>AlexLynn</name></author>
	</entry>
	<entry>
		<id>https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1481</id>
		<title>搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术</title>
		<link rel="alternate" type="text/html" href="https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1481"/>
		<updated>2026-03-01T06:00:28Z</updated>

		<summary type="html">&lt;p&gt;AlexLynn：​&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术 =&lt;br /&gt;
= BandwagonHost CN2 GIA &amp;amp; Komari: A Lightweight Go Probe Presenting the Art of Top-Tier Networking =&lt;br /&gt;
&lt;br /&gt;
搬瓦工（BandwagonHost）的 CN2 GIA 线路堪称 VPS 界的网络天花板。其三网顶级直连架构不仅带来了令人惊叹的极致超低延迟，更是在晚高峰也能保持全天候 &#039;&#039;&#039;0 丢包&#039;&#039;&#039; 的神话。这种丝滑、纯粹的网络体验，如果不配上一个优秀的现代监控探针将其彻底可视化，简直是暴殄天物！&lt;br /&gt;
BandwagonHost&#039;s CN2 GIA routing is arguably the network ceiling of the VPS world. Its top-tier direct connection across all three major networks brings not only amazingly stable and low latency but also maintains a mythical &#039;&#039;&#039;0 packet loss&#039;&#039;&#039; even during peak hours. Such a silky-smooth and pure network experience would be an absolute waste if not thoroughly visualized with an excellent modern monitoring dashboard!&lt;br /&gt;
&lt;br /&gt;
为了不辜负瓦工如此顶级的线路，我们需要一款同样极致的探针。今天的主角 &#039;&#039;&#039;Komari&#039;&#039;&#039; 正是为此而生。&lt;br /&gt;
To live up to such top-tier routing from BandwagonHost, we need an equally ultimate probe. Today&#039;s protagonist, &#039;&#039;&#039;Komari&#039;&#039;&#039;, was born for this exact purpose.&lt;br /&gt;
&lt;br /&gt;
== 为什么选择 Komari？ / Why Choose Komari? ==&lt;br /&gt;
&lt;br /&gt;
[[File:Komari.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
市面上的服务器监控面板琳琅满目，但 Komari 凭借其独特的架构脱颖而出：&lt;br /&gt;
The market is full of server monitoring panels, but Komari stands out with its unique architecture:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;基于 Go 语言构建 / Built with Go&#039;&#039;&#039;：Komari 的主控端和 Agent 均采用 Golang 编写。天生的高并发优势和出色的内存管理，使得它能以极低的系统资源占用，轻松处理并发连接。&amp;lt;br&amp;gt;Komari&#039;s controller and agent are both written in Golang. Its inherent high-concurrency advantages and excellent memory management allow it to easily handle concurrent connections with extremely low system resource consumption.&lt;br /&gt;
* &#039;&#039;&#039;优雅的 Controller + Agent 架构 / Elegant Controller + Agent Architecture&#039;&#039;&#039;：主控面板（Controller）负责节点管理与数据展示，轻量 Agent 负责采集系统指标，并通过 WebSocket 持久连接上报数据。这种设计避免了传统轮询式监控产生的大量请求开销，在低带宽 VPS 环境下依然能够保持高实时性与极低资源占用。&amp;lt;br&amp;gt;The controller dashboard is responsible for node management and data presentation, while the lightweight Agent collects system metrics and reports data via persistent WebSocket connections. This design avoids the massive request overhead generated by traditional polling-based monitoring, maintaining high real-time performance and extremely low resource usage even in low-bandwidth VPS environments.&lt;br /&gt;
* &#039;&#039;&#039;极致轻量与极简主义 / Extreme Lightweight &amp;amp; Minimalism&#039;&#039;&#039;：监控工具本身不应成为服务器的负担。Komari 没有臃肿的依赖库，对于极其珍贵的瓦工服务器资源来说，运行它几乎是“零感知”的。&amp;lt;br&amp;gt;Monitoring tools themselves shouldn&#039;t be a burden on the server. Komari has no bloated dependency libraries; for the extremely precious BandwagonHost server resources, running it is almost &amp;quot;zero-perception&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
本文将通过严谨的逻辑，一步一步完成 Komari 的基础部署、高级安全反代，以及多节点 Agent 的接入。&lt;br /&gt;
This article will walk through the basic deployment of Komari, advanced secure reverse proxy configuration, and multi-node Agent integration, step-by-step with rigorous logic.&lt;br /&gt;
&lt;br /&gt;
== 第一步：基础安装 - 部署 Komari 主控 / Step 1: Basic Installation - Deploying Komari Controller ==&lt;br /&gt;
&lt;br /&gt;
无论你是在白天使用 Windows 办公，还是使用 macOS 的终端，请先通过 SSH 接入你的搬瓦工服务器。为了保证环境的隔离性和未来排错的便利性，我们采用 Docker Compose 进行部署。&lt;br /&gt;
Whether you are working on Windows during the day or using the macOS terminal, please SSH into your BandwagonHost server first. To ensure environmental isolation and ease of future troubleshooting, we will deploy using Docker Compose.&lt;br /&gt;
&lt;br /&gt;
=== 1. 创建项目目录结构 / Create Project Directory Structure ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /opt/komari &amp;amp;&amp;amp; cd /opt/komari&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. 编写 Docker Compose 配置文件 / Write the Docker Compose Configuration ===&lt;br /&gt;
创建并编辑 Docker Compose 配置文件：&lt;br /&gt;
Create and edit the Docker Compose configuration file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano docker-compose.yml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下内容（注意端口映射的安全加固与版本控制）：&lt;br /&gt;
Write the following content (note the security hardening of port mapping and version control):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
version: &#039;3.8&#039;&lt;br /&gt;
services:&lt;br /&gt;
  komari:&lt;br /&gt;
    # 生产环境建议将 latest 替换为具体的 release 版本号以保证系统稳定性&lt;br /&gt;
    # For production, it&#039;s recommended to replace &#039;latest&#039; with a specific release version to ensure system stability&lt;br /&gt;
    image: ghcr.io/komari-monitor/komari:latest&lt;br /&gt;
    container_name: komari&lt;br /&gt;
    restart: unless-stopped&lt;br /&gt;
    ports:&lt;br /&gt;
      - &amp;quot;127.0.0.1:25774:25774&amp;quot;&lt;br /&gt;
    volumes:&lt;br /&gt;
      - ./data:/app/data&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与安全分析逻辑 / Debugging &amp;amp; Security Analysis Logic&lt;br /&gt;
: &#039;&#039;&#039;为什么映射 `/app/data`？ / Why map `/app/data`?&#039;&#039;&#039; 探针的面板设置、节点信息都物理存储在这个目录。如果不做映射，一旦容器重启或销毁，所有配置数据将全部丢失。 (The panel settings and node information are physically stored in this directory. If not mapped, all configuration data will be completely lost once the container restarts or is destroyed.)&lt;br /&gt;
: &#039;&#039;&#039;安全加固 `127.0.0.1`： / Security Hardening `127.0.0.1`:&#039;&#039;&#039; 绑定本地环回地址 `127.0.0.1`，杜绝被批量扫描及 0day 漏洞攻击的潜在威胁。 (Binding to the local loopback address `127.0.0.1` eliminates the potential threat of being bulk-scanned and attacked by 0-day vulnerabilities.)&lt;br /&gt;
&lt;br /&gt;
=== 3. 启动服务 / Start the Service ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker compose up -d&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
启动后，执行 `docker logs komari` 查看系统自动生成的初始管理员账号和密码。&lt;br /&gt;
After starting, execute `docker logs komari` to view the initial admin account and password automatically generated by the system.&lt;br /&gt;
&lt;br /&gt;
== 第二步：进阶配置 - Caddy 详尽反代与 HTTPS / Step 2: Advanced Configuration - Detailed Caddy Reverse Proxy &amp;amp; HTTPS ==&lt;br /&gt;
&lt;br /&gt;
在前端，我们将使用 Caddy 申请免费证书并进行反向代理，将安全的 HTTPS 流量转发给内网的 Komari。&lt;br /&gt;
On the frontend, we will use Caddy to request a free certificate and set up a reverse proxy to forward secure HTTPS traffic to the internal Komari service.&lt;br /&gt;
&lt;br /&gt;
=== 1. 编辑 Caddyfile / Edit the Caddyfile ===&lt;br /&gt;
打开你的 Caddy 配置文件（通常位于 `/etc/caddy/Caddyfile`）：&lt;br /&gt;
Open your Caddy config file (usually located at `/etc/caddy/Caddyfile`):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下配置（请将 `status.yourdomain.com` 替换为你的真实域名）：&lt;br /&gt;
Write the following configuration (please replace `status.yourdomain.com` with your real domain name):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
status.yourdomain.com {&lt;br /&gt;
    # 启用现代 TLS 协议 / Enable modern TLS protocols&lt;br /&gt;
    tls {&lt;br /&gt;
        protocols tls1.2 tls1.3&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 反向代理至本地环回地址的 Komari 端口 / Reverse proxy to the Komari port on the local loopback address&lt;br /&gt;
    reverse_proxy localhost:25774 {&lt;br /&gt;
        # 传递真实访客 IP 和协议 / Pass real visitor IP and protocol&lt;br /&gt;
        header_up Host {host}&lt;br /&gt;
        header_up X-Real-IP {remote}&lt;br /&gt;
        header_up X-Forwarded-For {remote}&lt;br /&gt;
        header_up X-Forwarded-Proto {scheme}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    # 启用压缩机制以加快探针面板加载速度 / Enable compression to speed up dashboard loading&lt;br /&gt;
    encode gzip zstd&lt;br /&gt;
&lt;br /&gt;
    # 现代且严谨的安全响应头设置 / Modern and rigorous security response headers setup&lt;br /&gt;
    header {&lt;br /&gt;
        # 注意：此处未加 preload，只有在你准备将域名提交到浏览器 HSTS preload list 时才建议加入 preload 参数&lt;br /&gt;
        # Note: &#039;preload&#039; is omitted here; it is only recommended if you plan to submit the domain to the browser HSTS preload list&lt;br /&gt;
        Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        X-Content-Type-Options &amp;quot;nosniff&amp;quot;&lt;br /&gt;
        X-Frame-Options &amp;quot;SAMEORIGIN&amp;quot;&lt;br /&gt;
        Referrer-Policy &amp;quot;strict-origin-when-cross-origin&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 详尽的访问日志记录，为未来排错提供明确的数据分析支持 / Detailed access logging to provide clear data support for future debugging&lt;br /&gt;
    log {&lt;br /&gt;
        output file /var/log/caddy/komari_access.log {&lt;br /&gt;
            roll_size 100mb&lt;br /&gt;
            roll_keep 5&lt;br /&gt;
        }&lt;br /&gt;
        format json&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与排错逻辑 / Debugging &amp;amp; Troubleshooting Logic&lt;br /&gt;
: &#039;&#039;&#039;WebSocket 断连与 Cloudflare 避坑： / WebSocket Disconnection &amp;amp; Cloudflare Pitfalls:&#039;&#039;&#039; Komari 极其依赖 WebSocket 进行实时数据推送（Caddy v2 默认原生支持 WebSocket 转发）。如果你发现面板卡死不刷新，请首先检查链路。如果你在前端套用了 Cloudflare，请务必检查：1. 网络设置中的 &amp;quot;WebSockets&amp;quot; 选项是否开启；2. SSL/TLS 加密模式必须设置为 &amp;quot;Full&amp;quot; 或 &amp;quot;Full (Strict)&amp;quot;，否则会导致循环重定向或握手失败。 (Komari heavily relies on WebSocket for real-time data push. If the panel freezes, check the link first. If using Cloudflare, ensure: 1. &amp;quot;WebSockets&amp;quot; is enabled in Network settings; 2. SSL/TLS mode is set to &amp;quot;Full&amp;quot; or &amp;quot;Full (Strict)&amp;quot; to prevent redirect loops or handshake failures.)&lt;br /&gt;
: &#039;&#039;&#039;日志分析排错： / Log Analysis Troubleshooting:&#039;&#039;&#039; 这里专门配置了 `/var/log/caddy/komari_access.log`。如果配置完出现 502 错误，切忌盲目瞎猜，直接使用 `tail -f /var/log/caddy/komari_access.log` 追踪日志，通过分析 HTTP 状态码和 Upstream 报错来精准定位问题。 (We specifically configured `/var/log/caddy/komari_access.log`. If a 502 error occurs, do not guess blindly; directly use `tail -f` to track the log and pinpoint the issue by analyzing HTTP status codes and Upstream errors.)&lt;br /&gt;
&lt;br /&gt;
=== 2. 重载 Caddy 生效 / Reload Caddy to Apply ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
caddy reload --config /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 第三步：多节点 Agent 接入实战 / Step 3: Multi-Node Agent Integration Practice ==&lt;br /&gt;
&lt;br /&gt;
主控端稳如泰山后，现在我们可以把其他 VPS 统一接入面板进行管理了。&lt;br /&gt;
With the controller stable as a mountain, we can now integrate your other VPS nodes into the dashboard for unified management.&lt;br /&gt;
&lt;br /&gt;
=== 1. 主控端获取连接参数 / Get Connection Parameters from Controller ===&lt;br /&gt;
登录你的 Komari 面板后台，点击“添加节点”。系统会为你生成一串专属的 Agent 连接命令，其中包含了你的 &#039;&#039;&#039;API 地址&#039;&#039;&#039; 和对应节点的 &#039;&#039;&#039;Secret Key&#039;&#039;&#039;。&lt;br /&gt;
Log into your Komari dashboard backend and click &amp;quot;Add Node&amp;quot;. The system will generate a dedicated Agent connection command containing your &#039;&#039;&#039;API Address&#039;&#039;&#039; and the corresponding node&#039;s &#039;&#039;&#039;Secret Key&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== 2. 在被控节点安装 Agent / Install Agent on the Managed Node ===&lt;br /&gt;
通过 SSH 登录到你需要监控的服务器，为了保持系统整洁，我们依然推荐使用 Docker 运行 Agent：&lt;br /&gt;
Log into the server you want to monitor via SSH. To keep the system clean, we still recommend running the Agent using Docker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker run -d \&lt;br /&gt;
  --name komari-agent \&lt;br /&gt;
  --restart unless-stopped \&lt;br /&gt;
  --net=host \&lt;br /&gt;
  -v /proc:/host/proc:ro \&lt;br /&gt;
  -v /sys:/host/sys:ro \&lt;br /&gt;
  -v /:/rootfs:ro \&lt;br /&gt;
  ghcr.io/komari-monitor/komari-agent:latest \&lt;br /&gt;
  -api &amp;quot;wss://status.yourdomain.com/api/v1/ws&amp;quot; \&lt;br /&gt;
  -secret &amp;quot;你的节点专属SecretKey&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与分析逻辑 / Debugging &amp;amp; Analysis Logic&lt;br /&gt;
: &#039;&#039;&#039;参数解析 `net=host` 与目录映射： / Parameter Parsing `net=host` and Directory Mapping:&#039;&#039;&#039; Agent 需要真实获取宿主机的网卡流量、CPU 和内存信息，因此必须使用 `--net=host` 共享网络命名空间，并将宿主机的 `/proc` 和 `/sys` 以只读 (`ro`) 模式映射进容器。 (The Agent needs to fetch real host network traffic, CPU, and memory info, so it must use `--net=host` to share the network namespace and map the host&#039;s `/proc` and `/sys` into the container in read-only (`ro`) mode.)&lt;br /&gt;
: &#039;&#039;&#039;协议检查： / Protocol Check:&#039;&#039;&#039; 确保 `-api` 参数使用的是 `wss://`（WebSocket Secure），因为我们的主控端已经配置了严格的 HTTPS。如果填成 `ws://` 将会被 Caddy 拒绝连接。 (Ensure the `-api` parameter uses `wss://` (WebSocket Secure) since our controller is configured with strict HTTPS. If filled as `ws://`, the connection will be rejected by Caddy.)&lt;br /&gt;
&lt;br /&gt;
大功告成！现在，你可以坐在屏幕前，看着所有服务器的绿色心跳线，享受数据掌控在自己手中的极致快感了。&lt;br /&gt;
Mission accomplished! Now, you can sit in front of the screen, watch the green heartbeat lines of all your servers, and enjoy the ultimate thrill of having your data under your own control.&lt;br /&gt;
&lt;br /&gt;
== 进阶探索与安全延展 / Advanced Exploration &amp;amp; Security Extension ==&lt;br /&gt;
&lt;br /&gt;
Komari 其实还有更多强大的进阶玩法等待你发掘。例如，你可以配置 Telegram Bot 接收服务器到期续费、流量预警、系统高负载以及延迟异常的实时推送（测速节点 IP 推荐在 zstaticcdn.com 获取）。此外，面板还支持高度定制化的美化主题。关于这些高级配置，篇幅所限不再展开，强烈建议访问 GitHub 搜索 `komari` 或直达官方文档 (https://komari-document.pages.dev/) 自行探索学习。&amp;lt;br&amp;gt;Komari actually has many more powerful advanced features waiting for you to discover. For instance, you can configure a Telegram Bot to receive real-time push notifications for server expiration renewals, traffic warnings, high system load, and abnormal latency (we recommend getting speed test node IPs from zstaticcdn.com). Additionally, the dashboard supports highly customizable aesthetic themes. Due to space constraints, we won&#039;t expand on these advanced configurations here. It is highly recommended to search for `komari` on GitHub or visit the official documentation (https://komari-document.pages.dev/) to explore and learn on your own.&lt;br /&gt;
&lt;br /&gt;
最后，虽然瓦工的线路极佳，但公网环境险恶。为了预防潜在的 DDoS 攻击或端口嗅探，你可以进一步研究如何为面板或网站套上“赛博菩萨” Cloudflare 的 Proxy (CDN) 甚至配置更为安全的 Cloudflare Tunnel。这些都是 VPS 玩家进阶的必修课，期待你查阅相关资料，继续点亮你的网络安全技能树！&amp;lt;br&amp;gt;Finally, although BandwagonHost&#039;s routing is excellent, the public internet environment is perilous. To prevent potential DDoS attacks or port sniffing, you can further research how to put your dashboard or website behind the &amp;quot;Cyber Bodhisattva&amp;quot; Cloudflare&#039;s Proxy (CDN) or even configure the much safer Cloudflare Tunnel. These are required courses for advanced VPS players. We look forward to you looking up relevant materials and continuing to light up your network security skill tree!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;Created by AlexLynn for md5.pw Community.&#039;&#039;&lt;br /&gt;
[[index.php?title=Category:500 常见应用指南 — Application Guides]]&lt;/div&gt;</summary>
		<author><name>AlexLynn</name></author>
	</entry>
	<entry>
		<id>https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1480</id>
		<title>搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术</title>
		<link rel="alternate" type="text/html" href="https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1480"/>
		<updated>2026-03-01T05:47:50Z</updated>

		<summary type="html">&lt;p&gt;AlexLynn：​&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术 =&lt;br /&gt;
= BandwagonHost CN2 GIA &amp;amp; Komari: A Lightweight Go Probe Presenting the Art of Top-Tier Networking =&lt;br /&gt;
&lt;br /&gt;
搬瓦工（BandwagonHost）的 CN2 GIA 线路堪称 VPS 界的网络天花板。其三网顶级直连架构不仅带来了令人惊叹的极致超低延迟，更是在晚高峰也能保持全天候 &#039;&#039;&#039;0 丢包&#039;&#039;&#039; 的神话。这种丝滑、纯粹的网络体验，如果不配上一个优秀的现代监控探针将其彻底可视化，简直是暴殄天物！&lt;br /&gt;
BandwagonHost&#039;s CN2 GIA routing is arguably the network ceiling of the VPS world. Its top-tier direct connection across all three major networks brings not only amazingly stable and low latency but also maintains a mythical &#039;&#039;&#039;0 packet loss&#039;&#039;&#039; even during peak hours. Such a silky-smooth and pure network experience would be an absolute waste if not thoroughly visualized with an excellent modern monitoring dashboard!&lt;br /&gt;
&lt;br /&gt;
为了不辜负瓦工如此顶级的线路，我们需要一款同样极致的探针。今天的主角 &#039;&#039;&#039;Komari&#039;&#039;&#039; 正是为此而生。&lt;br /&gt;
To live up to such top-tier routing from BandwagonHost, we need an equally ultimate probe. Today&#039;s protagonist, &#039;&#039;&#039;Komari&#039;&#039;&#039;, was born for this exact purpose.&lt;br /&gt;
&lt;br /&gt;
== 为什么选择 Komari？ / Why Choose Komari? ==&lt;br /&gt;
&lt;br /&gt;
[[File:Komari.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
市面上的服务器监控面板琳琅满目，但 Komari 凭借其独特的架构脱颖而出：&lt;br /&gt;
The market is full of server monitoring panels, but Komari stands out with its unique architecture:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;基于 Go 语言构建 / Built with Go&#039;&#039;&#039;：Komari 的主控端和 Agent 均采用 Golang 编写。天生的高并发优势和出色的内存管理，使得它能以极低的系统资源占用，轻松处理并发连接。&amp;lt;br&amp;gt;Komari&#039;s controller and agent are both written in Golang. Its inherent high-concurrency advantages and excellent memory management allow it to easily handle concurrent connections with extremely low system resource consumption.&lt;br /&gt;
* &#039;&#039;&#039;优雅的 Controller + Agent 架构 / Elegant Controller + Agent Architecture&#039;&#039;&#039;：主控面板（Controller）负责节点管理与数据展示，轻量 Agent 负责采集系统指标，并通过 WebSocket 持久连接上报数据。这种设计避免了传统轮询式监控产生的大量请求开销，在低带宽 VPS 环境下依然能够保持高实时性与极低资源占用。&amp;lt;br&amp;gt;The controller dashboard is responsible for node management and data presentation, while the lightweight Agent collects system metrics and reports data via persistent WebSocket connections. This design avoids the massive request overhead generated by traditional polling-based monitoring, maintaining high real-time performance and extremely low resource usage even in low-bandwidth VPS environments.&lt;br /&gt;
* &#039;&#039;&#039;极致轻量与极简主义 / Extreme Lightweight &amp;amp; Minimalism&#039;&#039;&#039;：监控工具本身不应成为服务器的负担。Komari 没有臃肿的依赖库，对于极其珍贵的瓦工服务器资源来说，运行它几乎是“零感知”的。&amp;lt;br&amp;gt;Monitoring tools themselves shouldn&#039;t be a burden on the server. Komari has no bloated dependency libraries; for the extremely precious BandwagonHost server resources, running it is almost &amp;quot;zero-perception&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
本文将通过严谨的逻辑，一步一步完成 Komari 的基础部署、高级安全反代，以及多节点 Agent 的接入。&lt;br /&gt;
This article will walk through the basic deployment of Komari, advanced secure reverse proxy configuration, and multi-node Agent integration, step-by-step with rigorous logic.&lt;br /&gt;
&lt;br /&gt;
== 第一步：基础安装 - 部署 Komari 主控 / Step 1: Basic Installation - Deploying Komari Controller ==&lt;br /&gt;
&lt;br /&gt;
无论你是在白天使用 Windows 办公，还是使用 macOS 的终端，请先通过 SSH 接入你的搬瓦工服务器。为了保证环境的隔离性和未来排错的便利性，我们采用 Docker Compose 进行部署。&lt;br /&gt;
Whether you are working on Windows during the day or using the macOS terminal, please SSH into your BandwagonHost server first. To ensure environmental isolation and ease of future troubleshooting, we will deploy using Docker Compose.&lt;br /&gt;
&lt;br /&gt;
=== 1. 创建项目目录结构 / Create Project Directory Structure ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /opt/komari &amp;amp;&amp;amp; cd /opt/komari&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. 编写 Docker Compose 配置文件 / Write the Docker Compose Configuration ===&lt;br /&gt;
创建并编辑 Docker Compose 配置文件：&lt;br /&gt;
Create and edit the Docker Compose configuration file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano docker-compose.yml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下内容（注意端口映射的安全加固与版本控制）：&lt;br /&gt;
Write the following content (note the security hardening of port mapping and version control):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
version: &#039;3.8&#039;&lt;br /&gt;
services:&lt;br /&gt;
  komari:&lt;br /&gt;
    # 生产环境建议将 latest 替换为具体的 release 版本号以保证系统稳定性&lt;br /&gt;
    # For production, it&#039;s recommended to replace &#039;latest&#039; with a specific release version to ensure system stability&lt;br /&gt;
    image: ghcr.io/komari-monitor/komari:latest&lt;br /&gt;
    container_name: komari&lt;br /&gt;
    restart: unless-stopped&lt;br /&gt;
    ports:&lt;br /&gt;
      - &amp;quot;127.0.0.1:25774:25774&amp;quot;&lt;br /&gt;
    volumes:&lt;br /&gt;
      - ./data:/app/data&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与安全分析逻辑 / Debugging &amp;amp; Security Analysis Logic&lt;br /&gt;
: &#039;&#039;&#039;为什么映射 `/app/data`？ / Why map `/app/data`?&#039;&#039;&#039; 探针的面板设置、节点信息都物理存储在这个目录。如果不做映射，一旦容器重启或销毁，所有配置数据将全部丢失。 (The panel settings and node information are physically stored in this directory. If not mapped, all configuration data will be completely lost once the container restarts or is destroyed.)&lt;br /&gt;
: &#039;&#039;&#039;安全加固 `127.0.0.1`： / Security Hardening `127.0.0.1`:&#039;&#039;&#039; 绑定本地环回地址 `127.0.0.1`，杜绝被批量扫描及 0day 漏洞攻击的潜在威胁。 (Binding to the local loopback address `127.0.0.1` eliminates the potential threat of being bulk-scanned and attacked by 0-day vulnerabilities.)&lt;br /&gt;
&lt;br /&gt;
=== 3. 启动服务 / Start the Service ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker compose up -d&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
启动后，执行 `docker logs komari` 查看系统自动生成的初始管理员账号和密码。&lt;br /&gt;
After starting, execute `docker logs komari` to view the initial admin account and password automatically generated by the system.&lt;br /&gt;
&lt;br /&gt;
== 第二步：进阶配置 - Caddy 详尽反代与 HTTPS / Step 2: Advanced Configuration - Detailed Caddy Reverse Proxy &amp;amp; HTTPS ==&lt;br /&gt;
&lt;br /&gt;
在前端，我们将使用 Caddy 申请免费证书并进行反向代理，将安全的 HTTPS 流量转发给内网的 Komari。&lt;br /&gt;
On the frontend, we will use Caddy to request a free certificate and set up a reverse proxy to forward secure HTTPS traffic to the internal Komari service.&lt;br /&gt;
&lt;br /&gt;
=== 1. 编辑 Caddyfile / Edit the Caddyfile ===&lt;br /&gt;
打开你的 Caddy 配置文件（通常位于 `/etc/caddy/Caddyfile`）：&lt;br /&gt;
Open your Caddy config file (usually located at `/etc/caddy/Caddyfile`):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下配置（请将 `status.yourdomain.com` 替换为你的真实域名）：&lt;br /&gt;
Write the following configuration (please replace `status.yourdomain.com` with your real domain name):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
status.yourdomain.com {&lt;br /&gt;
    # 启用现代 TLS 协议 / Enable modern TLS protocols&lt;br /&gt;
    tls {&lt;br /&gt;
        protocols tls1.2 tls1.3&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 反向代理至本地环回地址的 Komari 端口 / Reverse proxy to the Komari port on the local loopback address&lt;br /&gt;
    reverse_proxy localhost:25774 {&lt;br /&gt;
        # 传递真实访客 IP 和协议 / Pass real visitor IP and protocol&lt;br /&gt;
        header_up Host {host}&lt;br /&gt;
        header_up X-Real-IP {remote}&lt;br /&gt;
        header_up X-Forwarded-For {remote}&lt;br /&gt;
        header_up X-Forwarded-Proto {scheme}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    # 启用压缩机制以加快探针面板加载速度 / Enable compression to speed up dashboard loading&lt;br /&gt;
    encode gzip zstd&lt;br /&gt;
&lt;br /&gt;
    # 现代且严谨的安全响应头设置 / Modern and rigorous security response headers setup&lt;br /&gt;
    header {&lt;br /&gt;
        # 注意：此处未加 preload，只有在你准备将域名提交到浏览器 HSTS preload list 时才建议加入 preload 参数&lt;br /&gt;
        # Note: &#039;preload&#039; is omitted here; it is only recommended if you plan to submit the domain to the browser HSTS preload list&lt;br /&gt;
        Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        X-Content-Type-Options &amp;quot;nosniff&amp;quot;&lt;br /&gt;
        X-Frame-Options &amp;quot;SAMEORIGIN&amp;quot;&lt;br /&gt;
        Referrer-Policy &amp;quot;strict-origin-when-cross-origin&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 详尽的访问日志记录，为未来排错提供明确的数据分析支持 / Detailed access logging to provide clear data support for future debugging&lt;br /&gt;
    log {&lt;br /&gt;
        output file /var/log/caddy/komari_access.log {&lt;br /&gt;
            roll_size 100mb&lt;br /&gt;
            roll_keep 5&lt;br /&gt;
        }&lt;br /&gt;
        format json&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与排错逻辑 / Debugging &amp;amp; Troubleshooting Logic&lt;br /&gt;
: &#039;&#039;&#039;WebSocket 断连与 Cloudflare 避坑： / WebSocket Disconnection &amp;amp; Cloudflare Pitfalls:&#039;&#039;&#039; Komari 极其依赖 WebSocket 进行实时数据推送（Caddy v2 默认原生支持 WebSocket 转发）。如果你发现面板卡死不刷新，请首先检查链路。如果你在前端套用了 Cloudflare，请务必检查：1. 网络设置中的 &amp;quot;WebSockets&amp;quot; 选项是否开启；2. SSL/TLS 加密模式必须设置为 &amp;quot;Full&amp;quot; 或 &amp;quot;Full (Strict)&amp;quot;，否则会导致循环重定向或握手失败。 (Komari heavily relies on WebSocket for real-time data push. If the panel freezes, check the link first. If using Cloudflare, ensure: 1. &amp;quot;WebSockets&amp;quot; is enabled in Network settings; 2. SSL/TLS mode is set to &amp;quot;Full&amp;quot; or &amp;quot;Full (Strict)&amp;quot; to prevent redirect loops or handshake failures.)&lt;br /&gt;
: &#039;&#039;&#039;日志分析排错： / Log Analysis Troubleshooting:&#039;&#039;&#039; 这里专门配置了 `/var/log/caddy/komari_access.log`。如果配置完出现 502 错误，切忌盲目瞎猜，直接使用 `tail -f /var/log/caddy/komari_access.log` 追踪日志，通过分析 HTTP 状态码和 Upstream 报错来精准定位问题。 (We specifically configured `/var/log/caddy/komari_access.log`. If a 502 error occurs, do not guess blindly; directly use `tail -f` to track the log and pinpoint the issue by analyzing HTTP status codes and Upstream errors.)&lt;br /&gt;
&lt;br /&gt;
=== 2. 重载 Caddy 生效 / Reload Caddy to Apply ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
caddy reload --config /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 第三步：多节点 Agent 接入实战 / Step 3: Multi-Node Agent Integration Practice ==&lt;br /&gt;
&lt;br /&gt;
主控端稳如泰山后，现在我们可以把其他 VPS 统一接入面板进行管理了。&lt;br /&gt;
With the controller stable as a mountain, we can now integrate your other VPS nodes into the dashboard for unified management.&lt;br /&gt;
&lt;br /&gt;
=== 1. 主控端获取连接参数 / Get Connection Parameters from Controller ===&lt;br /&gt;
登录你的 Komari 面板后台，点击“添加节点”。系统会为你生成一串专属的 Agent 连接命令，其中包含了你的 &#039;&#039;&#039;API 地址&#039;&#039;&#039; 和对应节点的 &#039;&#039;&#039;Secret Key&#039;&#039;&#039;。&lt;br /&gt;
Log into your Komari dashboard backend and click &amp;quot;Add Node&amp;quot;. The system will generate a dedicated Agent connection command containing your &#039;&#039;&#039;API Address&#039;&#039;&#039; and the corresponding node&#039;s &#039;&#039;&#039;Secret Key&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== 2. 在被控节点安装 Agent / Install Agent on the Managed Node ===&lt;br /&gt;
通过 SSH 登录到你需要监控的服务器，为了保持系统整洁，我们依然推荐使用 Docker 运行 Agent：&lt;br /&gt;
Log into the server you want to monitor via SSH. To keep the system clean, we still recommend running the Agent using Docker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker run -d \&lt;br /&gt;
  --name komari-agent \&lt;br /&gt;
  --restart unless-stopped \&lt;br /&gt;
  --net=host \&lt;br /&gt;
  -v /proc:/host/proc:ro \&lt;br /&gt;
  -v /sys:/host/sys:ro \&lt;br /&gt;
  -v /:/rootfs:ro \&lt;br /&gt;
  ghcr.io/komari-monitor/komari-agent:latest \&lt;br /&gt;
  -api &amp;quot;wss://status.yourdomain.com/api/v1/ws&amp;quot; \&lt;br /&gt;
  -secret &amp;quot;你的节点专属SecretKey&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与分析逻辑 / Debugging &amp;amp; Analysis Logic&lt;br /&gt;
: &#039;&#039;&#039;参数解析 `net=host` 与目录映射： / Parameter Parsing `net=host` and Directory Mapping:&#039;&#039;&#039; Agent 需要真实获取宿主机的网卡流量、CPU 和内存信息，因此必须使用 `--net=host` 共享网络命名空间，并将宿主机的 `/proc` 和 `/sys` 以只读 (`ro`) 模式映射进容器。 (The Agent needs to fetch real host network traffic, CPU, and memory info, so it must use `--net=host` to share the network namespace and map the host&#039;s `/proc` and `/sys` into the container in read-only (`ro`) mode.)&lt;br /&gt;
: &#039;&#039;&#039;协议检查： / Protocol Check:&#039;&#039;&#039; 确保 `-api` 参数使用的是 `wss://`（WebSocket Secure），因为我们的主控端已经配置了严格的 HTTPS。如果填成 `ws://` 将会被 Caddy 拒绝连接。 (Ensure the `-api` parameter uses `wss://` (WebSocket Secure) since our controller is configured with strict HTTPS. If filled as `ws://`, the connection will be rejected by Caddy.)&lt;br /&gt;
&lt;br /&gt;
大功告成！现在，你可以坐在屏幕前，看着所有服务器的绿色心跳线，享受数据掌控在自己手中的极致快感了。&lt;br /&gt;
Mission accomplished! Now, you can sit in front of the screen, watch the green heartbeat lines of all your servers, and enjoy the ultimate thrill of having your data under your own control.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;Created by AlexLynn for md5.pw Community.&#039;&#039;&lt;br /&gt;
[[Category:500 常见应用指南 — Application Guides]]&lt;/div&gt;</summary>
		<author><name>AlexLynn</name></author>
	</entry>
	<entry>
		<id>https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1479</id>
		<title>搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术</title>
		<link rel="alternate" type="text/html" href="https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1479"/>
		<updated>2026-03-01T05:41:25Z</updated>

		<summary type="html">&lt;p&gt;AlexLynn：​&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术 =&lt;br /&gt;
= BandwagonHost CN2 GIA &amp;amp; Komari: A Lightweight Go Probe Presenting the Art of Top-Tier Networking =&lt;br /&gt;
&lt;br /&gt;
搬瓦工（BandwagonHost）的 CN2 GIA 线路堪称 VPS 界的网络天花板。其三网顶级直连架构不仅带来了令人惊叹的极致超低延迟，更是在晚高峰也能保持全天候 &#039;&#039;&#039;0 丢包&#039;&#039;&#039; 的神话。这种丝滑、纯粹的网络体验，如果不配上一个优秀的现代监控探针将其彻底可视化，简直是暴殄天物！&lt;br /&gt;
BandwagonHost&#039;s CN2 GIA routing is arguably the network ceiling of the VPS world. Its top-tier direct connection across all three major networks brings not only amazingly stable and low latency but also maintains a mythical &#039;&#039;&#039;0 packet loss&#039;&#039;&#039; even during peak hours. Such a silky-smooth and pure network experience would be an absolute waste if not thoroughly visualized with an excellent modern monitoring dashboard!&lt;br /&gt;
&lt;br /&gt;
为了不辜负瓦工如此顶级的线路，我们需要一款同样极致的探针。今天的主角 &#039;&#039;&#039;Komari&#039;&#039;&#039; 正是为此而生。&lt;br /&gt;
To live up to such top-tier routing from BandwagonHost, we need an equally ultimate probe. Today&#039;s protagonist, &#039;&#039;&#039;Komari&#039;&#039;&#039;, was born for this exact purpose.&lt;br /&gt;
&lt;br /&gt;
== 为什么选择 Komari？ / Why Choose Komari? ==&lt;br /&gt;
&lt;br /&gt;
[[File:Komari.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
市面上的服务器监控面板琳琅满目，但 Komari 凭借其独特的架构脱颖而出：&lt;br /&gt;
The market is full of server monitoring panels, but Komari stands out with its unique architecture:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;基于 Go 语言构建 / Built with Go&#039;&#039;&#039;：Komari 的主控端和 Agent 均采用 Golang 编写。天生的高并发优势和出色的内存管理，使得它能以极低的系统资源占用，轻松处理并发连接。&amp;lt;br&amp;gt;Komari&#039;s controller and agent are both written in Golang. Its inherent high-concurrency advantages and excellent memory management allow it to easily handle concurrent connections with extremely low system resource consumption.&lt;br /&gt;
* &#039;&#039;&#039;优雅的 Controller + Agent 架构 / Elegant Controller + Agent Architecture&#039;&#039;&#039;：主控面板（Controller）负责节点管理与数据展示，轻量 Agent 负责采集系统指标，并通过 WebSocket 持久连接上报数据。这种设计避免了传统轮询式监控产生的大量请求开销，在低带宽 VPS 环境下依然能够保持高实时性与极低资源占用。&amp;lt;br&amp;gt;The controller dashboard is responsible for node management and data presentation, while the lightweight Agent collects system metrics and reports data via persistent WebSocket connections. This design avoids the massive request overhead generated by traditional polling-based monitoring, maintaining high real-time performance and extremely low resource usage even in low-bandwidth VPS environments.&lt;br /&gt;
* &#039;&#039;&#039;极致轻量与极简主义 / Extreme Lightweight &amp;amp; Minimalism&#039;&#039;&#039;：监控工具本身不应成为服务器的负担。Komari 没有臃肿的依赖库，对于极其珍贵的瓦工服务器资源来说，运行它几乎是“零感知”的。&amp;lt;br&amp;gt;Monitoring tools themselves shouldn&#039;t be a burden on the server. Komari has no bloated dependency libraries; for the extremely precious BandwagonHost server resources, running it is almost &amp;quot;zero-perception&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
本文将通过严谨的逻辑，一步一步完成 Komari 的基础部署、高级安全反代，以及多节点 Agent 的接入。&lt;br /&gt;
This article will walk through the basic deployment of Komari, advanced secure reverse proxy configuration, and multi-node Agent integration, step-by-step with rigorous logic.&lt;br /&gt;
&lt;br /&gt;
== 第一步：基础安装 - 部署 Komari 主控 / Step 1: Basic Installation - Deploying Komari Controller ==&lt;br /&gt;
&lt;br /&gt;
无论你是在白天使用 Windows 办公，还是使用 macOS 的终端，请先通过 SSH 接入你的搬瓦工服务器。为了保证环境的隔离性和未来排错的便利性，我们采用 Docker Compose 进行部署。&lt;br /&gt;
Whether you are working on Windows during the day or using the macOS terminal, please SSH into your BandwagonHost server first. To ensure environmental isolation and ease of future troubleshooting, we will deploy using Docker Compose.&lt;br /&gt;
&lt;br /&gt;
=== 1. 创建项目目录结构 / Create Project Directory Structure ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /opt/komari &amp;amp;&amp;amp; cd /opt/komari&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. 编写 Docker Compose 配置文件 / Write the Docker Compose Configuration ===&lt;br /&gt;
创建并编辑 Docker Compose 配置文件：&lt;br /&gt;
Create and edit the Docker Compose configuration file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano docker-compose.yml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下内容（注意端口映射的安全加固与版本控制）：&lt;br /&gt;
Write the following content (note the security hardening of port mapping and version control):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
version: &#039;3.8&#039;&lt;br /&gt;
services:&lt;br /&gt;
  komari:&lt;br /&gt;
    # 生产环境建议将 latest 替换为具体的 release 版本号以保证系统稳定性&lt;br /&gt;
    # For production, it&#039;s recommended to replace &#039;latest&#039; with a specific release version to ensure system stability&lt;br /&gt;
    image: ghcr.io/komari-monitor/komari:latest&lt;br /&gt;
    container_name: komari&lt;br /&gt;
    restart: unless-stopped&lt;br /&gt;
    ports:&lt;br /&gt;
      - &amp;quot;127.0.0.1:25774:25774&amp;quot;&lt;br /&gt;
    volumes:&lt;br /&gt;
      - ./data:/app/data&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与安全分析逻辑 / Debugging &amp;amp; Security Analysis Logic&lt;br /&gt;
: &#039;&#039;&#039;为什么映射 `/app/data`？ / Why map `/app/data`?&#039;&#039;&#039; 探针的面板设置、节点信息都物理存储在这个目录。如果不做映射，一旦容器重启或销毁，所有配置数据将全部丢失。 (The panel settings and node information are physically stored in this directory. If not mapped, all configuration data will be completely lost once the container restarts or is destroyed.)&lt;br /&gt;
: &#039;&#039;&#039;安全加固 `127.0.0.1`： / Security Hardening `127.0.0.1`:&#039;&#039;&#039; 绑定本地环回地址 `127.0.0.1`，杜绝被批量扫描及 0day 漏洞攻击的潜在威胁。 (Binding to the local loopback address `127.0.0.1` eliminates the potential threat of being bulk-scanned and attacked by 0-day vulnerabilities.)&lt;br /&gt;
&lt;br /&gt;
=== 3. 启动服务 / Start the Service ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker compose up -d&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
启动后，执行 `docker logs komari` 查看系统自动生成的初始管理员账号和密码。&lt;br /&gt;
After starting, execute `docker logs komari` to view the initial admin account and password automatically generated by the system.&lt;br /&gt;
&lt;br /&gt;
== 第二步：进阶配置 - Caddy 详尽反代与 HTTPS / Step 2: Advanced Configuration - Detailed Caddy Reverse Proxy &amp;amp; HTTPS ==&lt;br /&gt;
&lt;br /&gt;
在前端，我们将使用 Caddy 申请免费证书并进行反向代理，将安全的 HTTPS 流量转发给内网的 Komari。&lt;br /&gt;
On the frontend, we will use Caddy to request a free certificate and set up a reverse proxy to forward secure HTTPS traffic to the internal Komari service.&lt;br /&gt;
&lt;br /&gt;
=== 1. 编辑 Caddyfile / Edit the Caddyfile ===&lt;br /&gt;
打开你的 Caddy 配置文件（通常位于 `/etc/caddy/Caddyfile`）：&lt;br /&gt;
Open your Caddy config file (usually located at `/etc/caddy/Caddyfile`):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下配置（请将 `status.yourdomain.com` 替换为你的真实域名）：&lt;br /&gt;
Write the following configuration (please replace `status.yourdomain.com` with your real domain name):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
status.yourdomain.com {&lt;br /&gt;
    # 启用现代 TLS 协议 / Enable modern TLS protocols&lt;br /&gt;
    tls {&lt;br /&gt;
        protocols tls1.2 tls1.3&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 反向代理至本地环回地址的 Komari 端口 / Reverse proxy to the Komari port on the local loopback address&lt;br /&gt;
    reverse_proxy localhost:25774 {&lt;br /&gt;
        # 传递真实访客 IP 和协议 / Pass real visitor IP and protocol&lt;br /&gt;
        header_up Host {host}&lt;br /&gt;
        header_up X-Real-IP {remote}&lt;br /&gt;
        header_up X-Forwarded-For {remote}&lt;br /&gt;
        header_up X-Forwarded-Proto {scheme}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    # 启用压缩机制以加快探针面板加载速度 / Enable compression to speed up dashboard loading&lt;br /&gt;
    encode gzip zstd&lt;br /&gt;
&lt;br /&gt;
    # 现代且严谨的安全响应头设置 / Modern and rigorous security response headers setup&lt;br /&gt;
    header {&lt;br /&gt;
        # 注意：此处未加 preload，只有在你准备将域名提交到浏览器 HSTS preload list 时才建议加入 preload 参数&lt;br /&gt;
        # Note: &#039;preload&#039; is omitted here; it is only recommended if you plan to submit the domain to the browser HSTS preload list&lt;br /&gt;
        Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        X-Content-Type-Options &amp;quot;nosniff&amp;quot;&lt;br /&gt;
        X-Frame-Options &amp;quot;SAMEORIGIN&amp;quot;&lt;br /&gt;
        Referrer-Policy &amp;quot;strict-origin-when-cross-origin&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 详尽的访问日志记录，为未来排错提供明确的数据分析支持 / Detailed access logging to provide clear data support for future debugging&lt;br /&gt;
    log {&lt;br /&gt;
        output file /var/log/caddy/komari_access.log {&lt;br /&gt;
            roll_size 100mb&lt;br /&gt;
            roll_keep 5&lt;br /&gt;
        }&lt;br /&gt;
        format json&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与排错逻辑 / Debugging &amp;amp; Troubleshooting Logic&lt;br /&gt;
: &#039;&#039;&#039;WebSocket 断连与 Cloudflare 避坑： / WebSocket Disconnection &amp;amp; Cloudflare Pitfalls:&#039;&#039;&#039; Komari 极其依赖 WebSocket 进行实时数据推送（Caddy v2 默认原生支持 WebSocket 转发）。如果你发现面板卡死不刷新，请首先检查链路。如果你在前端套用了 Cloudflare，请务必检查：1. 网络设置中的 &amp;quot;WebSockets&amp;quot; 选项是否开启；2. SSL/TLS 加密模式必须设置为 &amp;quot;Full&amp;quot; 或 &amp;quot;Full (Strict)&amp;quot;，否则会导致循环重定向或握手失败。 (Komari heavily relies on WebSocket for real-time data push. If the panel freezes, check the link first. If using Cloudflare, ensure: 1. &amp;quot;WebSockets&amp;quot; is enabled in Network settings; 2. SSL/TLS mode is set to &amp;quot;Full&amp;quot; or &amp;quot;Full (Strict)&amp;quot; to prevent redirect loops or handshake failures.)&lt;br /&gt;
: &#039;&#039;&#039;日志分析排错： / Log Analysis Troubleshooting:&#039;&#039;&#039; 这里专门配置了 `/var/log/caddy/komari_access.log`。如果配置完出现 502 错误，切忌盲目瞎猜，直接使用 `tail -f /var/log/caddy/komari_access.log` 追踪日志，通过分析 HTTP 状态码和 Upstream 报错来精准定位问题。 (We specifically configured `/var/log/caddy/komari_access.log`. If a 502 error occurs, do not guess blindly; directly use `tail -f` to track the log and pinpoint the issue by analyzing HTTP status codes and Upstream errors.)&lt;br /&gt;
&lt;br /&gt;
=== 2. 重载 Caddy 生效 / Reload Caddy to Apply ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
caddy reload --config /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 第三步：多节点 Agent 接入实战 / Step 3: Multi-Node Agent Integration Practice ==&lt;br /&gt;
&lt;br /&gt;
主控端稳如泰山后，现在我们可以把其他 VPS 统一接入面板进行管理了。&lt;br /&gt;
With the controller stable as a mountain, we can now integrate your other VPS nodes into the dashboard for unified management.&lt;br /&gt;
&lt;br /&gt;
=== 1. 主控端获取连接参数 / Get Connection Parameters from Controller ===&lt;br /&gt;
登录你的 Komari 面板后台，点击“添加节点”。系统会为你生成一串专属的 Agent 连接命令，其中包含了你的 &#039;&#039;&#039;API 地址&#039;&#039;&#039; 和对应节点的 &#039;&#039;&#039;Secret Key&#039;&#039;&#039;。&lt;br /&gt;
Log into your Komari dashboard backend and click &amp;quot;Add Node&amp;quot;. The system will generate a dedicated Agent connection command containing your &#039;&#039;&#039;API Address&#039;&#039;&#039; and the corresponding node&#039;s &#039;&#039;&#039;Secret Key&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== 2. 在被控节点安装 Agent / Install Agent on the Managed Node ===&lt;br /&gt;
通过 SSH 登录到你需要监控的服务器，为了保持系统整洁，我们依然推荐使用 Docker 运行 Agent：&lt;br /&gt;
Log into the server you want to monitor via SSH. To keep the system clean, we still recommend running the Agent using Docker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker run -d \&lt;br /&gt;
  --name komari-agent \&lt;br /&gt;
  --restart unless-stopped \&lt;br /&gt;
  --net=host \&lt;br /&gt;
  -v /proc:/host/proc:ro \&lt;br /&gt;
  -v /sys:/host/sys:ro \&lt;br /&gt;
  -v /:/rootfs:ro \&lt;br /&gt;
  ghcr.io/komari-monitor/komari-agent:latest \&lt;br /&gt;
  -api &amp;quot;wss://status.yourdomain.com/api/v1/ws&amp;quot; \&lt;br /&gt;
  -secret &amp;quot;你的节点专属SecretKey&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与分析逻辑 / Debugging &amp;amp; Analysis Logic&lt;br /&gt;
: &#039;&#039;&#039;参数解析 `net=host` 与目录映射： / Parameter Parsing `net=host` and Directory Mapping:&#039;&#039;&#039; Agent 需要真实获取宿主机的网卡流量、CPU 和内存信息，因此必须使用 `--net=host` 共享网络命名空间，并将宿主机的 `/proc` 和 `/sys` 以只读 (`ro`) 模式映射进容器。 (The Agent needs to fetch real host network traffic, CPU, and memory info, so it must use `--net=host` to share the network namespace and map the host&#039;s `/proc` and `/sys` into the container in read-only (`ro`) mode.)&lt;br /&gt;
: &#039;&#039;&#039;协议检查： / Protocol Check:&#039;&#039;&#039; 确保 `-api` 参数使用的是 `wss://`（WebSocket Secure），因为我们的主控端已经配置了严格的 HTTPS。如果填成 `ws://` 将会被 Caddy 拒绝连接。 (Ensure the `-api` parameter uses `wss://` (WebSocket Secure) since our controller is configured with strict HTTPS. If filled as `ws://`, the connection will be rejected by Caddy.)&lt;br /&gt;
&lt;br /&gt;
大功告成！现在，你可以坐在屏幕前，看着所有服务器的绿色心跳线，享受数据掌控在自己手中的极致快感了。&lt;br /&gt;
Mission accomplished! Now, you can sit in front of the screen, watch the green heartbeat lines of all your servers, and enjoy the ultimate thrill of having your data under your own control.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;Created by AlexLynn for md5.pw Community.&#039;&#039;&lt;br /&gt;
[[index.php?title=Category:500 常见应用指南 — Application Guides]]&lt;/div&gt;</summary>
		<author><name>AlexLynn</name></author>
	</entry>
	<entry>
		<id>https://md5.pw/index.php?title=File:Komari.png&amp;diff=1478</id>
		<title>File:Komari.png</title>
		<link rel="alternate" type="text/html" href="https://md5.pw/index.php?title=File:Komari.png&amp;diff=1478"/>
		<updated>2026-03-01T05:40:59Z</updated>

		<summary type="html">&lt;p&gt;AlexLynn：​&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;description&lt;/div&gt;</summary>
		<author><name>AlexLynn</name></author>
	</entry>
	<entry>
		<id>https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1477</id>
		<title>搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术</title>
		<link rel="alternate" type="text/html" href="https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1477"/>
		<updated>2026-03-01T05:30:07Z</updated>

		<summary type="html">&lt;p&gt;AlexLynn：​&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术 =&lt;br /&gt;
= BandwagonHost CN2 GIA &amp;amp; Komari: A Lightweight Go Probe Presenting the Art of Top-Tier Networking =&lt;br /&gt;
&lt;br /&gt;
搬瓦工（BandwagonHost）的 CN2 GIA 线路堪称 VPS 界的网络天花板。其三网顶级直连架构不仅带来了令人惊叹的极致超低延迟，更是在晚高峰也能保持全天候 &#039;&#039;&#039;0 丢包&#039;&#039;&#039; 的神话。这种丝滑、纯粹的网络体验，如果不配上一个优秀的现代监控探针将其彻底可视化，简直是暴殄天物！&lt;br /&gt;
BandwagonHost&#039;s CN2 GIA routing is arguably the network ceiling of the VPS world. Its top-tier direct connection across all three major networks brings not only amazingly stable and low latency but also maintains a mythical &#039;&#039;&#039;0 packet loss&#039;&#039;&#039; even during peak hours. Such a silky-smooth and pure network experience would be an absolute waste if not thoroughly visualized with an excellent modern monitoring dashboard!&lt;br /&gt;
&lt;br /&gt;
为了不辜负瓦工如此顶级的线路，我们需要一款同样极致的探针。今天的主角 &#039;&#039;&#039;Komari&#039;&#039;&#039; 正是为此而生。&lt;br /&gt;
To live up to such top-tier routing from BandwagonHost, we need an equally ultimate probe. Today&#039;s protagonist, &#039;&#039;&#039;Komari&#039;&#039;&#039;, was born for this exact purpose.&lt;br /&gt;
&lt;br /&gt;
== 为什么选择 Komari？ / Why Choose Komari? ==&lt;br /&gt;
&lt;br /&gt;
市面上的服务器监控面板琳琅满目，但 Komari 凭借其独特的架构脱颖而出：&lt;br /&gt;
The market is full of server monitoring panels, but Komari stands out with its unique architecture:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;基于 Go 语言构建 / Built with Go&#039;&#039;&#039;：Komari 的主控端和 Agent 均采用 Golang 编写。天生的高并发优势和出色的内存管理，使得它能以极低的系统资源占用，轻松处理并发连接。&amp;lt;br&amp;gt;Komari&#039;s controller and agent are both written in Golang. Its inherent high-concurrency advantages and excellent memory management allow it to easily handle concurrent connections with extremely low system resource consumption.&lt;br /&gt;
* &#039;&#039;&#039;优雅的 Controller + Agent 架构 / Elegant Controller + Agent Architecture&#039;&#039;&#039;：主控面板（Controller）负责节点管理与数据展示，轻量 Agent 负责采集系统指标，并通过 WebSocket 持久连接上报数据。这种设计避免了传统轮询式监控产生的大量请求开销，在低带宽 VPS 环境下依然能够保持高实时性与极低资源占用。&amp;lt;br&amp;gt;The controller dashboard is responsible for node management and data presentation, while the lightweight Agent collects system metrics and reports data via persistent WebSocket connections. This design avoids the massive request overhead generated by traditional polling-based monitoring, maintaining high real-time performance and extremely low resource usage even in low-bandwidth VPS environments.&lt;br /&gt;
* &#039;&#039;&#039;极致轻量与极简主义 / Extreme Lightweight &amp;amp; Minimalism&#039;&#039;&#039;：监控工具本身不应成为服务器的负担。Komari 没有臃肿的依赖库，对于极其珍贵的瓦工服务器资源来说，运行它几乎是“零感知”的。&amp;lt;br&amp;gt;Monitoring tools themselves shouldn&#039;t be a burden on the server. Komari has no bloated dependency libraries; for the extremely precious BandwagonHost server resources, running it is almost &amp;quot;zero-perception&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
本文将通过严谨的逻辑，一步一步完成 Komari 的基础部署、高级安全反代，以及多节点 Agent 的接入。&lt;br /&gt;
This article will walk through the basic deployment of Komari, advanced secure reverse proxy configuration, and multi-node Agent integration, step-by-step with rigorous logic.&lt;br /&gt;
&lt;br /&gt;
== 第一步：基础安装 - 部署 Komari 主控 / Step 1: Basic Installation - Deploying Komari Controller ==&lt;br /&gt;
&lt;br /&gt;
无论你是在白天使用 Windows 办公，还是使用 macOS 的终端，请先通过 SSH 接入你的搬瓦工服务器。为了保证环境的隔离性和未来排错的便利性，我们采用 Docker Compose 进行部署。&lt;br /&gt;
Whether you are working on Windows during the day or using the macOS terminal, please SSH into your BandwagonHost server first. To ensure environmental isolation and ease of future troubleshooting, we will deploy using Docker Compose.&lt;br /&gt;
&lt;br /&gt;
=== 1. 创建项目目录结构 / Create Project Directory Structure ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /opt/komari &amp;amp;&amp;amp; cd /opt/komari&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. 编写 Docker Compose 配置文件 / Write the Docker Compose Configuration ===&lt;br /&gt;
创建并编辑 Docker Compose 配置文件：&lt;br /&gt;
Create and edit the Docker Compose configuration file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano docker-compose.yml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下内容（注意端口映射的安全加固与版本控制）：&lt;br /&gt;
Write the following content (note the security hardening of port mapping and version control):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
version: &#039;3.8&#039;&lt;br /&gt;
services:&lt;br /&gt;
  komari:&lt;br /&gt;
    # 生产环境建议将 latest 替换为具体的 release 版本号以保证系统稳定性&lt;br /&gt;
    # For production, it&#039;s recommended to replace &#039;latest&#039; with a specific release version to ensure system stability&lt;br /&gt;
    image: ghcr.io/komari-monitor/komari:latest&lt;br /&gt;
    container_name: komari&lt;br /&gt;
    restart: unless-stopped&lt;br /&gt;
    ports:&lt;br /&gt;
      - &amp;quot;127.0.0.1:25774:25774&amp;quot;&lt;br /&gt;
    volumes:&lt;br /&gt;
      - ./data:/app/data&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与安全分析逻辑 / Debugging &amp;amp; Security Analysis Logic&lt;br /&gt;
: &#039;&#039;&#039;为什么映射 `/app/data`？ / Why map `/app/data`?&#039;&#039;&#039; 探针的面板设置、节点信息都物理存储在这个目录。如果不做映射，一旦容器重启或销毁，所有配置数据将全部丢失。 (The panel settings and node information are physically stored in this directory. If not mapped, all configuration data will be completely lost once the container restarts or is destroyed.)&lt;br /&gt;
: &#039;&#039;&#039;安全加固 `127.0.0.1`： / Security Hardening `127.0.0.1`:&#039;&#039;&#039; 绑定本地环回地址 `127.0.0.1`，杜绝被批量扫描及 0day 漏洞攻击的潜在威胁。 (Binding to the local loopback address `127.0.0.1` eliminates the potential threat of being bulk-scanned and attacked by 0-day vulnerabilities.)&lt;br /&gt;
&lt;br /&gt;
=== 3. 启动服务 / Start the Service ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker compose up -d&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
启动后，执行 `docker logs komari` 查看系统自动生成的初始管理员账号和密码。&lt;br /&gt;
After starting, execute `docker logs komari` to view the initial admin account and password automatically generated by the system.&lt;br /&gt;
&lt;br /&gt;
== 第二步：进阶配置 - Caddy 详尽反代与 HTTPS / Step 2: Advanced Configuration - Detailed Caddy Reverse Proxy &amp;amp; HTTPS ==&lt;br /&gt;
&lt;br /&gt;
在前端，我们将使用 Caddy 申请免费证书并进行反向代理，将安全的 HTTPS 流量转发给内网的 Komari。&lt;br /&gt;
On the frontend, we will use Caddy to request a free certificate and set up a reverse proxy to forward secure HTTPS traffic to the internal Komari service.&lt;br /&gt;
&lt;br /&gt;
=== 1. 编辑 Caddyfile / Edit the Caddyfile ===&lt;br /&gt;
打开你的 Caddy 配置文件（通常位于 `/etc/caddy/Caddyfile`）：&lt;br /&gt;
Open your Caddy config file (usually located at `/etc/caddy/Caddyfile`):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下配置（请将 `status.yourdomain.com` 替换为你的真实域名）：&lt;br /&gt;
Write the following configuration (please replace `status.yourdomain.com` with your real domain name):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
status.yourdomain.com {&lt;br /&gt;
    # 启用现代 TLS 协议 / Enable modern TLS protocols&lt;br /&gt;
    tls {&lt;br /&gt;
        protocols tls1.2 tls1.3&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 反向代理至本地环回地址的 Komari 端口 / Reverse proxy to the Komari port on the local loopback address&lt;br /&gt;
    reverse_proxy localhost:25774 {&lt;br /&gt;
        # 传递真实访客 IP 和协议 / Pass real visitor IP and protocol&lt;br /&gt;
        header_up Host {host}&lt;br /&gt;
        header_up X-Real-IP {remote}&lt;br /&gt;
        header_up X-Forwarded-For {remote}&lt;br /&gt;
        header_up X-Forwarded-Proto {scheme}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    # 启用压缩机制以加快探针面板加载速度 / Enable compression to speed up dashboard loading&lt;br /&gt;
    encode gzip zstd&lt;br /&gt;
&lt;br /&gt;
    # 现代且严谨的安全响应头设置 / Modern and rigorous security response headers setup&lt;br /&gt;
    header {&lt;br /&gt;
        # 注意：此处未加 preload，只有在你准备将域名提交到浏览器 HSTS preload list 时才建议加入 preload 参数&lt;br /&gt;
        # Note: &#039;preload&#039; is omitted here; it is only recommended if you plan to submit the domain to the browser HSTS preload list&lt;br /&gt;
        Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        X-Content-Type-Options &amp;quot;nosniff&amp;quot;&lt;br /&gt;
        X-Frame-Options &amp;quot;SAMEORIGIN&amp;quot;&lt;br /&gt;
        Referrer-Policy &amp;quot;strict-origin-when-cross-origin&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 详尽的访问日志记录，为未来排错提供明确的数据分析支持 / Detailed access logging to provide clear data support for future debugging&lt;br /&gt;
    log {&lt;br /&gt;
        output file /var/log/caddy/komari_access.log {&lt;br /&gt;
            roll_size 100mb&lt;br /&gt;
            roll_keep 5&lt;br /&gt;
        }&lt;br /&gt;
        format json&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与排错逻辑 / Debugging &amp;amp; Troubleshooting Logic&lt;br /&gt;
: &#039;&#039;&#039;WebSocket 断连与 Cloudflare 避坑： / WebSocket Disconnection &amp;amp; Cloudflare Pitfalls:&#039;&#039;&#039; Komari 极其依赖 WebSocket 进行实时数据推送（Caddy v2 默认原生支持 WebSocket 转发）。如果你发现面板卡死不刷新，请首先检查链路。如果你在前端套用了 Cloudflare，请务必检查：1. 网络设置中的 &amp;quot;WebSockets&amp;quot; 选项是否开启；2. SSL/TLS 加密模式必须设置为 &amp;quot;Full&amp;quot; 或 &amp;quot;Full (Strict)&amp;quot;，否则会导致循环重定向或握手失败。 (Komari heavily relies on WebSocket for real-time data push. If the panel freezes, check the link first. If using Cloudflare, ensure: 1. &amp;quot;WebSockets&amp;quot; is enabled in Network settings; 2. SSL/TLS mode is set to &amp;quot;Full&amp;quot; or &amp;quot;Full (Strict)&amp;quot; to prevent redirect loops or handshake failures.)&lt;br /&gt;
: &#039;&#039;&#039;日志分析排错： / Log Analysis Troubleshooting:&#039;&#039;&#039; 这里专门配置了 `/var/log/caddy/komari_access.log`。如果配置完出现 502 错误，切忌盲目瞎猜，直接使用 `tail -f /var/log/caddy/komari_access.log` 追踪日志，通过分析 HTTP 状态码和 Upstream 报错来精准定位问题。 (We specifically configured `/var/log/caddy/komari_access.log`. If a 502 error occurs, do not guess blindly; directly use `tail -f` to track the log and pinpoint the issue by analyzing HTTP status codes and Upstream errors.)&lt;br /&gt;
&lt;br /&gt;
=== 2. 重载 Caddy 生效 / Reload Caddy to Apply ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
caddy reload --config /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 第三步：多节点 Agent 接入实战 / Step 3: Multi-Node Agent Integration Practice ==&lt;br /&gt;
&lt;br /&gt;
主控端稳如泰山后，现在我们可以把其他 VPS 统一接入面板进行管理了。&lt;br /&gt;
With the controller stable as a mountain, we can now integrate your other VPS nodes into the dashboard for unified management.&lt;br /&gt;
&lt;br /&gt;
=== 1. 主控端获取连接参数 / Get Connection Parameters from Controller ===&lt;br /&gt;
登录你的 Komari 面板后台，点击“添加节点”。系统会为你生成一串专属的 Agent 连接命令，其中包含了你的 &#039;&#039;&#039;API 地址&#039;&#039;&#039; 和对应节点的 &#039;&#039;&#039;Secret Key&#039;&#039;&#039;。&lt;br /&gt;
Log into your Komari dashboard backend and click &amp;quot;Add Node&amp;quot;. The system will generate a dedicated Agent connection command containing your &#039;&#039;&#039;API Address&#039;&#039;&#039; and the corresponding node&#039;s &#039;&#039;&#039;Secret Key&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== 2. 在被控节点安装 Agent / Install Agent on the Managed Node ===&lt;br /&gt;
通过 SSH 登录到你需要监控的服务器，为了保持系统整洁，我们依然推荐使用 Docker 运行 Agent：&lt;br /&gt;
Log into the server you want to monitor via SSH. To keep the system clean, we still recommend running the Agent using Docker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker run -d \&lt;br /&gt;
  --name komari-agent \&lt;br /&gt;
  --restart unless-stopped \&lt;br /&gt;
  --net=host \&lt;br /&gt;
  -v /proc:/host/proc:ro \&lt;br /&gt;
  -v /sys:/host/sys:ro \&lt;br /&gt;
  -v /:/rootfs:ro \&lt;br /&gt;
  ghcr.io/komari-monitor/komari-agent:latest \&lt;br /&gt;
  -api &amp;quot;wss://status.yourdomain.com/api/v1/ws&amp;quot; \&lt;br /&gt;
  -secret &amp;quot;你的节点专属SecretKey&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与分析逻辑 / Debugging &amp;amp; Analysis Logic&lt;br /&gt;
: &#039;&#039;&#039;参数解析 `net=host` 与目录映射： / Parameter Parsing `net=host` and Directory Mapping:&#039;&#039;&#039; Agent 需要真实获取宿主机的网卡流量、CPU 和内存信息，因此必须使用 `--net=host` 共享网络命名空间，并将宿主机的 `/proc` 和 `/sys` 以只读 (`ro`) 模式映射进容器。 (The Agent needs to fetch real host network traffic, CPU, and memory info, so it must use `--net=host` to share the network namespace and map the host&#039;s `/proc` and `/sys` into the container in read-only (`ro`) mode.)&lt;br /&gt;
: &#039;&#039;&#039;协议检查： / Protocol Check:&#039;&#039;&#039; 确保 `-api` 参数使用的是 `wss://`（WebSocket Secure），因为我们的主控端已经配置了严格的 HTTPS。如果填成 `ws://` 将会被 Caddy 拒绝连接。 (Ensure the `-api` parameter uses `wss://` (WebSocket Secure) since our controller is configured with strict HTTPS. If filled as `ws://`, the connection will be rejected by Caddy.)&lt;br /&gt;
&lt;br /&gt;
大功告成！现在，你可以坐在屏幕前，看着所有服务器的绿色心跳线，享受数据掌控在自己手中的极致快感了。&lt;br /&gt;
Mission accomplished! Now, you can sit in front of the screen, watch the green heartbeat lines of all your servers, and enjoy the ultimate thrill of having your data under your own control.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;Created by AlexLynn for md5.pw Community.&#039;&#039;&lt;br /&gt;
[[index.php?title=Category:500 常见应用指南 — Application Guides]]&lt;/div&gt;</summary>
		<author><name>AlexLynn</name></author>
	</entry>
	<entry>
		<id>https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1476</id>
		<title>搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术</title>
		<link rel="alternate" type="text/html" href="https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1476"/>
		<updated>2026-03-01T05:24:03Z</updated>

		<summary type="html">&lt;p&gt;AlexLynn：​&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术 =&lt;br /&gt;
= BandwagonHost CN2 GIA &amp;amp; Komari: A Lightweight Go Probe Presenting the Art of Top-Tier Networking =&lt;br /&gt;
&lt;br /&gt;
搬瓦工（BandwagonHost）的 CN2 GIA 线路堪称 VPS 界的网络天花板。其三网顶级直连架构不仅带来了令人惊叹的极致超低延迟，更是在晚高峰也能保持全天候 &#039;&#039;&#039;0 丢包&#039;&#039;&#039; 的神话。这种丝滑、纯粹的网络体验，如果不配上一个优秀的现代监控探针将其彻底可视化，简直是暴殄天物！&lt;br /&gt;
BandwagonHost&#039;s CN2 GIA routing is arguably the network ceiling of the VPS world. Its top-tier direct connection across all three major networks brings not only amazingly stable and low latency but also maintains a mythical &#039;&#039;&#039;0 packet loss&#039;&#039;&#039; even during peak hours. Such a silky-smooth and pure network experience would be an absolute waste if not thoroughly visualized with an excellent modern monitoring dashboard!&lt;br /&gt;
&lt;br /&gt;
为了不辜负瓦工如此顶级的线路，我们需要一款同样极致的探针。今天的主角 &#039;&#039;&#039;Komari&#039;&#039;&#039; 正是为此而生。&lt;br /&gt;
To live up to such top-tier routing from BandwagonHost, we need an equally ultimate probe. Today&#039;s protagonist, &#039;&#039;&#039;Komari&#039;&#039;&#039;, was born for this exact purpose.&lt;br /&gt;
&lt;br /&gt;
== 为什么选择 Komari？ / Why Choose Komari? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
市面上的服务器监控面板琳琅满目，但 Komari 凭借其独特的架构脱颖而出：&lt;br /&gt;
The market is full of server monitoring panels, but Komari stands out with its unique architecture:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;基于 Go 语言构建 / Built with Go&#039;&#039;&#039;：Komari 的主控端和 Agent 均采用 Golang 编写。天生的高并发优势和出色的内存管理，使得它能以极低的系统资源占用，轻松处理并发连接。&lt;br /&gt;
  Komari&#039;s controller and agent are both written in Golang. Its inherent high-concurrency advantages and excellent memory management allow it to easily handle concurrent connections with extremely low system resource consumption.&lt;br /&gt;
* &#039;&#039;&#039;优雅的 Controller + Agent 架构 / Elegant Controller + Agent Architecture&#039;&#039;&#039;：主控面板（Controller）负责节点管理与数据展示，轻量 Agent 负责采集系统指标，并通过 WebSocket 持久连接上报数据。这种设计避免了传统轮询式监控产生的大量请求开销，在低带宽 VPS 环境下依然能够保持高实时性与极低资源占用。&lt;br /&gt;
  The controller dashboard is responsible for node management and data presentation, while the lightweight Agent collects system metrics and reports data via persistent WebSocket connections. This design avoids the massive request overhead generated by traditional polling-based monitoring, maintaining high real-time performance and extremely low resource usage even in low-bandwidth VPS environments.&lt;br /&gt;
* &#039;&#039;&#039;极致轻量与极简主义 / Extreme Lightweight &amp;amp; Minimalism&#039;&#039;&#039;：监控工具本身不应成为服务器的负担。Komari 没有臃肿的依赖库，对于极其珍贵的瓦工服务器资源来说，运行它几乎是“零感知”的。&lt;br /&gt;
  Monitoring tools themselves shouldn&#039;t be a burden on the server. Komari has no bloated dependency libraries; for the extremely precious BandwagonHost server resources, running it is almost &amp;quot;zero-perception&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
本文将通过严谨的逻辑，一步一步完成 Komari 的基础部署、高级安全反代，以及多节点 Agent 的接入。&lt;br /&gt;
This article will walk through the basic deployment of Komari, advanced secure reverse proxy configuration, and multi-node Agent integration, step-by-step with rigorous logic.&lt;br /&gt;
&lt;br /&gt;
== 第一步：基础安装 - 部署 Komari 主控 / Step 1: Basic Installation - Deploying Komari Controller ==&lt;br /&gt;
&lt;br /&gt;
无论你是在白天使用 Windows 办公，还是使用 macOS 的终端，请先通过 SSH 接入你的搬瓦工服务器。为了保证环境的隔离性和未来排错的便利性，我们采用 Docker Compose 进行部署。&lt;br /&gt;
Whether you are working on Windows during the day or using the macOS terminal, please SSH into your BandwagonHost server first. To ensure environmental isolation and ease of future troubleshooting, we will deploy using Docker Compose.&lt;br /&gt;
&lt;br /&gt;
=== 1. 创建项目目录结构 / Create Project Directory Structure ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /opt/komari &amp;amp;&amp;amp; cd /opt/komari&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. 编写 Docker Compose 配置文件 / Write the Docker Compose Configuration ===&lt;br /&gt;
创建并编辑 Docker Compose 配置文件：&lt;br /&gt;
Create and edit the Docker Compose configuration file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano docker-compose.yml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下内容（注意端口映射的安全加固与版本控制）：&lt;br /&gt;
Write the following content (note the security hardening of port mapping and version control):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
version: &#039;3.8&#039;&lt;br /&gt;
services:&lt;br /&gt;
  komari:&lt;br /&gt;
    # 生产环境建议将 latest 替换为具体的 release 版本号以保证系统稳定性&lt;br /&gt;
    # For production, it&#039;s recommended to replace &#039;latest&#039; with a specific release version to ensure system stability&lt;br /&gt;
    image: ghcr.io/komari-monitor/komari:latest&lt;br /&gt;
    container_name: komari&lt;br /&gt;
    restart: unless-stopped&lt;br /&gt;
    ports:&lt;br /&gt;
      - &amp;quot;127.0.0.1:25774:25774&amp;quot;&lt;br /&gt;
    volumes:&lt;br /&gt;
      - ./data:/app/data&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与安全分析逻辑 / Debugging &amp;amp; Security Analysis Logic&lt;br /&gt;
: &#039;&#039;&#039;为什么映射 `/app/data`？ / Why map `/app/data`?&#039;&#039;&#039; 探针的面板设置、节点信息都物理存储在这个目录。如果不做映射，一旦容器重启或销毁，所有配置数据将全部丢失。 (The panel settings and node information are physically stored in this directory. If not mapped, all configuration data will be completely lost once the container restarts or is destroyed.)&lt;br /&gt;
: &#039;&#039;&#039;安全加固 `127.0.0.1`： / Security Hardening `127.0.0.1`:&#039;&#039;&#039; 绑定本地环回地址 `127.0.0.1`，杜绝被批量扫描及 0day 漏洞攻击的潜在威胁。 (Binding to the local loopback address `127.0.0.1` eliminates the potential threat of being bulk-scanned and attacked by 0-day vulnerabilities.)&lt;br /&gt;
&lt;br /&gt;
=== 3. 启动服务 / Start the Service ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker compose up -d&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
启动后，执行 `docker logs komari` 查看系统自动生成的初始管理员账号和密码。&lt;br /&gt;
After starting, execute `docker logs komari` to view the initial admin account and password automatically generated by the system.&lt;br /&gt;
&lt;br /&gt;
== 第二步：进阶配置 - Caddy 详尽反代与 HTTPS / Step 2: Advanced Configuration - Detailed Caddy Reverse Proxy &amp;amp; HTTPS ==&lt;br /&gt;
&lt;br /&gt;
在前端，我们将使用 Caddy 申请免费证书并进行反向代理，将安全的 HTTPS 流量转发给内网的 Komari。&lt;br /&gt;
On the frontend, we will use Caddy to request a free certificate and set up a reverse proxy to forward secure HTTPS traffic to the internal Komari service.&lt;br /&gt;
&lt;br /&gt;
=== 1. 编辑 Caddyfile / Edit the Caddyfile ===&lt;br /&gt;
打开你的 Caddy 配置文件（通常位于 `/etc/caddy/Caddyfile`）：&lt;br /&gt;
Open your Caddy config file (usually located at `/etc/caddy/Caddyfile`):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下配置（请将 `status.yourdomain.com` 替换为你的真实域名）：&lt;br /&gt;
Write the following configuration (please replace `status.yourdomain.com` with your real domain name):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
status.yourdomain.com {&lt;br /&gt;
    # 启用现代 TLS 协议 / Enable modern TLS protocols&lt;br /&gt;
    tls {&lt;br /&gt;
        protocols tls1.2 tls1.3&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 反向代理至本地环回地址的 Komari 端口 / Reverse proxy to the Komari port on the local loopback address&lt;br /&gt;
    reverse_proxy localhost:25774 {&lt;br /&gt;
        # 传递真实访客 IP 和协议 / Pass real visitor IP and protocol&lt;br /&gt;
        header_up Host {host}&lt;br /&gt;
        header_up X-Real-IP {remote}&lt;br /&gt;
        header_up X-Forwarded-For {remote}&lt;br /&gt;
        header_up X-Forwarded-Proto {scheme}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    # 启用压缩机制以加快探针面板加载速度 / Enable compression to speed up dashboard loading&lt;br /&gt;
    encode gzip zstd&lt;br /&gt;
&lt;br /&gt;
    # 现代且严谨的安全响应头设置 / Modern and rigorous security response headers setup&lt;br /&gt;
    header {&lt;br /&gt;
        # 注意：此处未加 preload，只有在你准备将域名提交到浏览器 HSTS preload list 时才建议加入 preload 参数&lt;br /&gt;
        # Note: &#039;preload&#039; is omitted here; it is only recommended if you plan to submit the domain to the browser HSTS preload list&lt;br /&gt;
        Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot;&lt;br /&gt;
        X-Content-Type-Options &amp;quot;nosniff&amp;quot;&lt;br /&gt;
        X-Frame-Options &amp;quot;SAMEORIGIN&amp;quot;&lt;br /&gt;
        Referrer-Policy &amp;quot;strict-origin-when-cross-origin&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 详尽的访问日志记录，为未来排错提供明确的数据分析支持 / Detailed access logging to provide clear data support for future debugging&lt;br /&gt;
    log {&lt;br /&gt;
        output file /var/log/caddy/komari_access.log {&lt;br /&gt;
            roll_size 100mb&lt;br /&gt;
            roll_keep 5&lt;br /&gt;
        }&lt;br /&gt;
        format json&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与排错逻辑 / Debugging &amp;amp; Troubleshooting Logic&lt;br /&gt;
: &#039;&#039;&#039;WebSocket 断连与 Cloudflare 避坑： / WebSocket Disconnection &amp;amp; Cloudflare Pitfalls:&#039;&#039;&#039; Komari 极其依赖 WebSocket 进行实时数据推送（Caddy v2 默认原生支持 WebSocket 转发）。如果你发现面板卡死不刷新，请首先检查链路。如果你在前端套用了 Cloudflare，请务必检查：1. 网络设置中的 &amp;quot;WebSockets&amp;quot; 选项是否开启；2. SSL/TLS 加密模式必须设置为 &amp;quot;Full&amp;quot; 或 &amp;quot;Full (Strict)&amp;quot;，否则会导致循环重定向或握手失败。 (Komari heavily relies on WebSocket for real-time data push. If the panel freezes, check the link first. If using Cloudflare, ensure: 1. &amp;quot;WebSockets&amp;quot; is enabled in Network settings; 2. SSL/TLS mode is set to &amp;quot;Full&amp;quot; or &amp;quot;Full (Strict)&amp;quot; to prevent redirect loops or handshake failures.)&lt;br /&gt;
: &#039;&#039;&#039;日志分析排错： / Log Analysis Troubleshooting:&#039;&#039;&#039; 这里专门配置了 `/var/log/caddy/komari_access.log`。如果配置完出现 502 错误，切忌盲目瞎猜，直接使用 `tail -f /var/log/caddy/komari_access.log` 追踪日志，通过分析 HTTP 状态码和 Upstream 报错来精准定位问题。 (We specifically configured `/var/log/caddy/komari_access.log`. If a 502 error occurs, do not guess blindly; directly use `tail -f` to track the log and pinpoint the issue by analyzing HTTP status codes and Upstream errors.)&lt;br /&gt;
&lt;br /&gt;
=== 2. 重载 Caddy 生效 / Reload Caddy to Apply ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
caddy reload --config /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 第三步：多节点 Agent 接入实战 / Step 3: Multi-Node Agent Integration Practice ==&lt;br /&gt;
&lt;br /&gt;
主控端稳如泰山后，现在我们可以把其他 VPS 统一接入面板进行管理了。&lt;br /&gt;
With the controller stable as a mountain, we can now integrate your other VPS nodes into the dashboard for unified management.&lt;br /&gt;
&lt;br /&gt;
=== 1. 主控端获取连接参数 / Get Connection Parameters from Controller ===&lt;br /&gt;
登录你的 Komari 面板后台，点击“添加节点”。系统会为你生成一串专属的 Agent 连接命令，其中包含了你的 &#039;&#039;&#039;API 地址&#039;&#039;&#039; 和对应节点的 &#039;&#039;&#039;Secret Key&#039;&#039;&#039;。&lt;br /&gt;
Log into your Komari dashboard backend and click &amp;quot;Add Node&amp;quot;. The system will generate a dedicated Agent connection command containing your &#039;&#039;&#039;API Address&#039;&#039;&#039; and the corresponding node&#039;s &#039;&#039;&#039;Secret Key&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== 2. 在被控节点安装 Agent / Install Agent on the Managed Node ===&lt;br /&gt;
通过 SSH 登录到你需要监控的服务器，为了保持系统整洁，我们依然推荐使用 Docker 运行 Agent：&lt;br /&gt;
Log into the server you want to monitor via SSH . To keep the system clean, we still recommend running the Agent using Docker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker run -d \&lt;br /&gt;
  --name komari-agent \&lt;br /&gt;
  --restart unless-stopped \&lt;br /&gt;
  --net=host \&lt;br /&gt;
  -v /proc:/host/proc:ro \&lt;br /&gt;
  -v /sys:/host/sys:ro \&lt;br /&gt;
  -v /:/rootfs:ro \&lt;br /&gt;
  ghcr.io/komari-monitor/komari-agent:latest \&lt;br /&gt;
  -api &amp;quot;wss://status.yourdomain.com/api/v1/ws&amp;quot; \&lt;br /&gt;
  -secret &amp;quot;你的节点专属SecretKey&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与分析逻辑 / Debugging &amp;amp; Analysis Logic&lt;br /&gt;
: &#039;&#039;&#039;参数解析 `net=host` 与目录映射： / Parameter Parsing `net=host` and Directory Mapping:&#039;&#039;&#039; Agent 需要真实获取宿主机的网卡流量、CPU 和内存信息，因此必须使用 `--net=host` 共享网络命名空间，并将宿主机的 `/proc` 和 `/sys` 以只读 (`ro`) 模式映射进容器。 (The Agent needs to fetch real host network traffic, CPU, and memory info, so it must use `--net=host` to share the network namespace and map the host&#039;s `/proc` and `/sys` into the container in read-only (`ro`) mode.)&lt;br /&gt;
: &#039;&#039;&#039;协议检查： / Protocol Check:&#039;&#039;&#039; 确保 `-api` 参数使用的是 `wss://`（WebSocket Secure），因为我们的主控端已经配置了严格的 HTTPS。如果填成 `ws://` 将会被 Caddy 拒绝连接。 (Ensure the `-api` parameter uses `wss://` (WebSocket Secure) since our controller is configured with strict HTTPS. If filled as `ws://`, the connection will be rejected by Caddy.)&lt;br /&gt;
&lt;br /&gt;
大功告成！现在，你可以坐在屏幕前，看着所有服务器的绿色心跳线，享受数据掌控在自己手中的极致快感了。&lt;br /&gt;
Mission accomplished! Now, you can sit in front of the screen, watch the green heartbeat lines of all your servers, and enjoy the ultimate thrill of having your data under your own control.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;Created by AlexLynn for md5.pw Community.&#039;&#039;&lt;br /&gt;
[[Category:500 常见应用指南 — Application Guides]]&lt;/div&gt;</summary>
		<author><name>AlexLynn</name></author>
	</entry>
	<entry>
		<id>https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1475</id>
		<title>搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术</title>
		<link rel="alternate" type="text/html" href="https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5_CN2_GIA_%E4%B8%8E_Komari%EF%BC%9A%E8%BD%BB%E9%87%8F%E7%BA%A7_Go_%E8%AF%AD%E8%A8%80%E6%8E%A2%E9%92%88%E5%91%88%E7%8E%B0%E4%B8%89%E7%BD%91%E9%A1%B6%E7%BA%A7%E7%BD%91%E7%BB%9C%E8%89%BA%E6%9C%AF&amp;diff=1475"/>
		<updated>2026-03-01T05:08:14Z</updated>

		<summary type="html">&lt;p&gt;AlexLynn：​创建页面，内容为“= 搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术 =  搬瓦工（BandwagonHost）的 CN2 GIA 线路堪称 VPS 界的网络天花板。其三网顶级直连架构不仅带来了令人惊叹的极致超低延迟，更是在晚高峰也能保持全天候 &amp;#039;&amp;#039;&amp;#039;0 丢包&amp;#039;&amp;#039;&amp;#039; 的神话。这种丝滑、纯粹的网络体验，如果不配上一个优秀的现代监控探针将其彻底可视化，简直是暴殄天物！  为了不…”&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 搬瓦工 CN2 GIA 与 Komari：轻量级 Go 语言探针呈现三网顶级网络艺术 =&lt;br /&gt;
&lt;br /&gt;
搬瓦工（BandwagonHost）的 CN2 GIA 线路堪称 VPS 界的网络天花板。其三网顶级直连架构不仅带来了令人惊叹的极致超低延迟，更是在晚高峰也能保持全天候 &#039;&#039;&#039;0 丢包&#039;&#039;&#039; 的神话。这种丝滑、纯粹的网络体验，如果不配上一个优秀的现代监控探针将其彻底可视化，简直是暴殄天物！&lt;br /&gt;
&lt;br /&gt;
为了不辜负瓦工如此顶级的线路，我们需要一款同样极致的探针。今天的主角 &#039;&#039;&#039;Komari&#039;&#039;&#039; 正是为此而生。&lt;br /&gt;
&lt;br /&gt;
== 为什么选择 Komari？ ==&lt;br /&gt;
&lt;br /&gt;
市面上的服务器监控面板琳琅满目，但 Komari 凭借其独特的架构脱颖而出：&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;基于 Go 语言构建&#039;&#039;&#039;：Komari 的主控端和 Agent 均采用 Golang 编写。天生的高并发优势和出色的内存管理，使得它能以极低的系统资源占用，轻松处理并发连接。&lt;br /&gt;
* &#039;&#039;&#039;极致轻量与极简主义&#039;&#039;&#039;：监控工具本身不应成为服务器的负担。Komari 没有臃肿的依赖库，对于极其珍贵的瓦工服务器资源来说，运行它几乎是“零感知”的。&lt;br /&gt;
* &#039;&#039;&#039;优雅的数据流转&#039;&#039;&#039;：采用 WebSocket 进行实时数据推送，延迟极低。你在面板上看到的每一次心跳闪烁，都精准地反映了搬瓦工 CN2 GIA 线路坚如磐石的网络质量。&lt;br /&gt;
&lt;br /&gt;
本文将通过严谨的逻辑，一步一步完成 Komari 的基础部署，并进阶使用 Caddy 配置包含完整安全规范的 HTTPS 反向代理。&lt;br /&gt;
&lt;br /&gt;
== 第一步：基础安装 - 部署 Komari 主控 ==&lt;br /&gt;
&lt;br /&gt;
无论你是在白天使用 Windows 办公，还是使用 macOS 的终端，请先通过 SSH 接入你的搬瓦工服务器。为了保证环境的隔离性和未来排错的便利性，我们采用 Docker Compose 进行部署。&lt;br /&gt;
&lt;br /&gt;
=== 1. 创建项目目录结构 ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /opt/komari &amp;amp;&amp;amp; cd /opt/komari&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. 编写 docker-compose.yml ===&lt;br /&gt;
创建并编辑配置文件：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano docker-compose.yml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下内容：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
version: &#039;3.8&#039;&lt;br /&gt;
services:&lt;br /&gt;
  komari:&lt;br /&gt;
    image: ghcr.io/komari-monitor/komari:latest&lt;br /&gt;
    container_name: komari&lt;br /&gt;
    restart: unless-stopped&lt;br /&gt;
    ports:&lt;br /&gt;
      - &amp;quot;25774:25774&amp;quot;&lt;br /&gt;
    volumes:&lt;br /&gt;
      - ./data:/app/data&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与分析逻辑&lt;br /&gt;
: &#039;&#039;&#039;为什么映射 `/app/data`？&#039;&#039;&#039; 探针的面板设置、节点信息都存储在这个目录。如果不做物理映射，一旦容器重启或销毁，所有数据将全部丢失。&lt;br /&gt;
: &#039;&#039;&#039;关于端口 25774：&#039;&#039;&#039; 这是 Komari 的默认监听端口。如果启动后无法通过 IP 访问，排错的第一步不要瞎猜服务是否崩溃，而是严格检查服务器的 `ufw` 或 `iptables` 防火墙是否放行了 TCP 25774 端口。&lt;br /&gt;
&lt;br /&gt;
=== 3. 启动服务 ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker compose up -d&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
启动后，通过执行 `docker logs komari` 可以查看系统自动生成的初始管理员账号和密码。&lt;br /&gt;
&lt;br /&gt;
== 第二步：进阶配置 - Caddy 详尽反代与 HTTPS ==&lt;br /&gt;
&lt;br /&gt;
将面板直接暴露在 HTTP 端口是不安全的。我们将使用 Caddy 申请免费证书并进行反向代理。以下是一份&#039;&#039;&#039;完整且详尽&#039;&#039;&#039;的配置，而非精简的凑合版本。&lt;br /&gt;
&lt;br /&gt;
=== 1. 编辑 Caddyfile ===&lt;br /&gt;
打开你的 Caddy 配置文件（通常位于 `/etc/caddy/Caddyfile`）：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下配置（请将 `status.yourdomain.com` 替换为你的真实域名）：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
status.yourdomain.com {&lt;br /&gt;
    # 启用现代 TLS 协议&lt;br /&gt;
    tls {&lt;br /&gt;
        protocols tls1.2 tls1.3&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 反向代理至本地的 Komari 端口&lt;br /&gt;
    reverse_proxy localhost:25774 {&lt;br /&gt;
        # 传递真实访客 IP 和协议，避免后端获取到的全为本地 IP 127.0.0.1&lt;br /&gt;
        header_up Host {host}&lt;br /&gt;
        header_up X-Real-IP {remote}&lt;br /&gt;
        header_up X-Forwarded-For {remote}&lt;br /&gt;
        header_up X-Forwarded-Proto {scheme}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    # 启用压缩机制以加快探针面板加载速度&lt;br /&gt;
    encode gzip zstd&lt;br /&gt;
&lt;br /&gt;
    # 完整的安全响应头设置&lt;br /&gt;
    header {&lt;br /&gt;
        Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains; preload&amp;quot;&lt;br /&gt;
        X-Content-Type-Options &amp;quot;nosniff&amp;quot;&lt;br /&gt;
        X-Frame-Options &amp;quot;SAMEORIGIN&amp;quot;&lt;br /&gt;
        X-XSS-Protection &amp;quot;1; mode=block&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    # 详尽的访问日志记录，为未来排错提供明确的数据分析支持&lt;br /&gt;
    log {&lt;br /&gt;
        output file /var/log/caddy/komari_access.log {&lt;br /&gt;
            roll_size 100mb&lt;br /&gt;
            roll_keep 5&lt;br /&gt;
        }&lt;br /&gt;
        format json&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; 🔍 Debug 与分析逻辑&lt;br /&gt;
: &#039;&#039;&#039;Websocket 断连排错：&#039;&#039;&#039; Komari 极其依赖 Websocket 进行实时数据推送（注意：Caddy v2 默认原生支持 WebSocket 转发，无需手动配置 Upgrade 头）。如果你发现面板卡死不刷新，请首先检查链路。如果在外部套了 CDN（如 Cloudflare），排错的下一步是检查 CDN 控制台的 WebSocket 转发选项是否处于开启状态。&lt;br /&gt;
: &#039;&#039;&#039;日志分析排错：&#039;&#039;&#039; 这里专门配置了 `/var/log/caddy/komari_access.log`。如果配置完出现 502 错误，切忌盲目重启，直接使用 `tail -f /var/log/caddy/komari_access.log` 追踪日志。你能清晰地分析出是 Let&#039;s Encrypt 证书申请达到速率限制，还是后端的 `localhost:25774` 拒绝了连接请求。&lt;br /&gt;
&lt;br /&gt;
=== 2. 重载 Caddy 生效 ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
caddy reload --config /etc/caddy/Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
至此，一个架构完整、包含完善日志与安全头配置的 Komari 监控面板就搭建完成了。登录面板，看着各项指标的平稳绿线，细细品味搬瓦工带给你的极致网络享受吧。&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;Created by AlexLynn for md5.pw Community.&#039;&#039;&lt;br /&gt;
[[index.php?title=Category:500 常见应用指南 — Application Guides]]&lt;/div&gt;</summary>
		<author><name>AlexLynn</name></author>
	</entry>
	<entry>
		<id>https://md5.pw/index.php?title=%E6%95%B0%E6%8D%AE%E4%B8%BB%E6%9D%83%EF%BC%9A%E5%9C%A8%E6%90%AC%E7%93%A6%E5%B7%A5_VPS_%E4%B8%8A%E9%83%A8%E7%BD%B2_Vaultwarden_(Bitwarden)_%E5%AF%86%E7%A0%81%E7%AE%A1%E7%90%86%E5%99%A8&amp;diff=1057</id>
		<title>数据主权：在搬瓦工 VPS 上部署 Vaultwarden (Bitwarden) 密码管理器</title>
		<link rel="alternate" type="text/html" href="https://md5.pw/index.php?title=%E6%95%B0%E6%8D%AE%E4%B8%BB%E6%9D%83%EF%BC%9A%E5%9C%A8%E6%90%AC%E7%93%A6%E5%B7%A5_VPS_%E4%B8%8A%E9%83%A8%E7%BD%B2_Vaultwarden_(Bitwarden)_%E5%AF%86%E7%A0%81%E7%AE%A1%E7%90%86%E5%99%A8&amp;diff=1057"/>
		<updated>2026-01-23T06:16:46Z</updated>

		<summary type="html">&lt;p&gt;AlexLynn：​创建页面，内容为“= 数据主权：在搬瓦工 VPS 上部署 Vaultwarden (Bitwarden) 密码管理器 =  在数据泄露事件频发的今天，将密码托管在第三方服务器（如 LastPass）始终存在隐患。&amp;#039;&amp;#039;&amp;#039;Vaultwarden&amp;#039;&amp;#039;&amp;#039; 是大名鼎鼎的开源密码管理器 Bitwarden 的轻量化服务端（基于 Rust 编写），它完美兼容 Bitwarden 的所有官方客户端（iOS/Android/浏览器插件），但资源占用极低，非常适合在搬瓦工（BandwagonHo…”&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 数据主权：在搬瓦工 VPS 上部署 Vaultwarden (Bitwarden) 密码管理器 =&lt;br /&gt;
&lt;br /&gt;
在数据泄露事件频发的今天，将密码托管在第三方服务器（如 LastPass）始终存在隐患。&#039;&#039;&#039;Vaultwarden&#039;&#039;&#039; 是大名鼎鼎的开源密码管理器 Bitwarden 的轻量化服务端（基于 Rust 编写），它完美兼容 Bitwarden 的所有官方客户端（iOS/Android/浏览器插件），但资源占用极低，非常适合在搬瓦工（BandwagonHost）VPS 上运行。&lt;br /&gt;
&lt;br /&gt;
本文将指导你使用 Docker 搭建一套属于自己的、端到端加密的密码管理系统。&lt;br /&gt;
&lt;br /&gt;
== 为什么选择在搬瓦工自建？ ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;数据掌控&#039;&#039;&#039;：你的密码数据库加密存储在你自己的 VPS 磁盘上，不再受制于人。&lt;br /&gt;
* &#039;&#039;&#039;极致粘性&#039;&#039;&#039;：搬瓦工提供的高 SLA 保证和自动快照（Snapshot）功能，为密码库的持久化存储提供了双重保险。&lt;br /&gt;
* &#039;&#039;&#039;完全免费&#039;&#039;&#039;：解锁 Bitwarden 官方的高级会员功能（如 TOTP 二步验证、附件存储等）。&lt;br /&gt;
&lt;br /&gt;
== 准备工作 ==&lt;br /&gt;
&lt;br /&gt;
* 一台搬瓦工 VPS（任何套餐均可，内存 512MB 以上即可）。&lt;br /&gt;
* 一个域名（解析到 VPS 的 IP）。&lt;br /&gt;
* 已安装 Docker 和 Docker Compose。&lt;br /&gt;
&lt;br /&gt;
== 第一步：部署环境配置 ==&lt;br /&gt;
&lt;br /&gt;
为了简化 HTTPS 证书的申请过程，我们将使用 &#039;&#039;&#039;Caddy&#039;&#039;&#039; 作为 Web 服务器（它会自动申请并续期 SSL 证书），配合 Vaultwarden 运行。&lt;br /&gt;
&lt;br /&gt;
=== 1. 创建工作目录 ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /opt/vaultwarden&lt;br /&gt;
cd /opt/vaultwarden&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. 创建 docker-compose.yml ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano docker-compose.yml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下内容（&#039;&#039;&#039;请修改域名和 ADMIN_TOKEN&#039;&#039;&#039;）：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
version: &#039;3&#039;&lt;br /&gt;
&lt;br /&gt;
services:&lt;br /&gt;
  vaultwarden:&lt;br /&gt;
    image: vaultwarden/server:latest&lt;br /&gt;
    container_name: vaultwarden&lt;br /&gt;
    restart: always&lt;br /&gt;
    environment:&lt;br /&gt;
      # 开启管理后台，请生成一个复杂的随机字符串作为 Token&lt;br /&gt;
      # 可以在终端使用 `openssl rand -base64 48` 生成&lt;br /&gt;
      - ADMIN_TOKEN=请替换为你的随机长字符串&lt;br /&gt;
      # 允许注册 (建议搭建完成后改为 false 以关闭注册)&lt;br /&gt;
      - SIGNUPS_ALLOWED=true&lt;br /&gt;
    volumes:&lt;br /&gt;
      - ./vw-data:/data&lt;br /&gt;
&lt;br /&gt;
  caddy:&lt;br /&gt;
    image: caddy:2&lt;br /&gt;
    container_name: caddy&lt;br /&gt;
    restart: always&lt;br /&gt;
    ports:&lt;br /&gt;
      - &amp;quot;80:80&amp;quot;&lt;br /&gt;
      - &amp;quot;443:443&amp;quot;&lt;br /&gt;
    volumes:&lt;br /&gt;
      - ./Caddyfile:/etc/caddy/Caddyfile&lt;br /&gt;
      - ./caddy-data:/data&lt;br /&gt;
      - ./caddy-config:/config&lt;br /&gt;
    depends_on:&lt;br /&gt;
      - vaultwarden&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 3. 配置 Caddy 自动 HTTPS ===&lt;br /&gt;
创建 Caddy 配置文件：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano Caddyfile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
写入以下内容（将 `your-domain.com` 替换为你的真实域名）：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
your-domain.com {&lt;br /&gt;
    # 反向代理到 vaultwarden 容器的 80 端口&lt;br /&gt;
    reverse_proxy vaultwarden:80&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 第二步：启动服务 ==&lt;br /&gt;
&lt;br /&gt;
在 `/opt/vaultwarden` 目录下执行：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker compose up -d&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
稍等片刻，Caddy 会自动向 Let&#039;s Encrypt 申请 SSL 证书。打开浏览器访问你的域名 `https://your-domain.com`，如果看到蓝色的 Bitwarden 登录界面，说明部署成功！&lt;br /&gt;
&lt;br /&gt;
== 第三步：初始设置与安全加固 ==&lt;br /&gt;
&lt;br /&gt;
=== 1. 注册账号 ===&lt;br /&gt;
点击“创建账号”，注册你的主账号。&lt;br /&gt;
&lt;br /&gt;
=== 2. 关闭新用户注册（重要！） ===&lt;br /&gt;
为了防止陌生人恶意注册占用你的资源，建议注册完自己账号后，立即关闭注册功能。&lt;br /&gt;
&lt;br /&gt;
修改 `docker-compose.yml`：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
      - SIGNUPS_ALLOWED=false&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
然后重启容器生效：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
docker compose up -d&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 第四步：数据备份（核心） ==&lt;br /&gt;
&lt;br /&gt;
密码库是核心资产，&#039;&#039;&#039;备份重于泰山&#039;&#039;&#039;。得益于搬瓦工的 KiwiVM 面板，我们可以轻松保护数据。&lt;br /&gt;
&lt;br /&gt;
; 方案 A：KiwiVM 自动快照 (推荐)&lt;br /&gt;
: 进入搬瓦工 KiwiVM 后台 -&amp;gt; &#039;&#039;&#039;Snapshots&#039;&#039;&#039; -&amp;gt; 将 &#039;&#039;&#039;Automatic snapshots&#039;&#039;&#039; 设置为 &amp;quot;Sticky&amp;quot;（永久保留最新的 2 个快照）。这样即使你误删了文件，也能一键回滚。&lt;br /&gt;
&lt;br /&gt;
; 方案 B：手动导出&lt;br /&gt;
: 登录你的 Vaultwarden 网页版后台，定期在“工具” -&amp;gt; “导出密码库”中下载 JSON/CSV 备份。&lt;br /&gt;
&lt;br /&gt;
== 客户端连接方法 ==&lt;br /&gt;
&lt;br /&gt;
* 下载 Bitwarden 官方手机 App 或浏览器插件。&lt;br /&gt;
* 点击登录界面的 &#039;&#039;&#039;小齿轮图标&#039;&#039;&#039;（设置）。&lt;br /&gt;
* 在 &#039;&#039;&#039;自托管环境 (Self-hosted environment)&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;服务器 URL&#039;&#039;&#039; 中填入你的域名（例如 `https://your-domain.com`）。&lt;br /&gt;
* 保存后即可正常登录使用。&lt;br /&gt;
&lt;br /&gt;
== 常见问题 (FAQ) ==&lt;br /&gt;
&lt;br /&gt;
; Q: 为什么必须用 HTTPS？&lt;br /&gt;
: A: Bitwarden 的加密算法依赖于 Web Crypto API，现代浏览器强制要求该 API 必须在 HTTPS 环境下才能运行。如果不用 HTTPS，你将无法注册或登录。&lt;br /&gt;
&lt;br /&gt;
; Q: 内存占用大吗？&lt;br /&gt;
: A: 极小。Vaultwarden 基于 Rust 编写，空闲时内存占用通常仅需 20MB-50MB，即便是搬瓦工最入门的套餐也能流畅运行。&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;Created by AlexLynn for md5.pw Community.&#039;&#039;&lt;br /&gt;
[[Category:500 常见应用指南 — Application Guides]]&lt;br /&gt;
[[Category:300 VPS 设置与管理 — VPS Setup and Management]]&lt;/div&gt;</summary>
		<author><name>AlexLynn</name></author>
	</entry>
	<entry>
		<id>https://md5.pw/index.php?title=%E6%9E%81%E9%80%9F%E5%AE%89%E5%85%A8%EF%BC%9A%E5%9C%A8%E6%90%AC%E7%93%A6%E5%B7%A5_VPS_%E4%B8%8A%E9%83%A8%E7%BD%B2_WireGuard_(WG)_%E8%AF%A6%E7%BB%86%E6%8C%87%E5%8D%97&amp;diff=1056</id>
		<title>极速安全：在搬瓦工 VPS 上部署 WireGuard (WG) 详细指南</title>
		<link rel="alternate" type="text/html" href="https://md5.pw/index.php?title=%E6%9E%81%E9%80%9F%E5%AE%89%E5%85%A8%EF%BC%9A%E5%9C%A8%E6%90%AC%E7%93%A6%E5%B7%A5_VPS_%E4%B8%8A%E9%83%A8%E7%BD%B2_WireGuard_(WG)_%E8%AF%A6%E7%BB%86%E6%8C%87%E5%8D%97&amp;diff=1056"/>
		<updated>2026-01-23T05:53:05Z</updated>

		<summary type="html">&lt;p&gt;AlexLynn：​创建页面，内容为“= 极速安全：在搬瓦工 VPS 上部署 WireGuard (WG) 详细指南 =  &amp;#039;&amp;#039;&amp;#039;WireGuard&amp;#039;&amp;#039;&amp;#039; 是被整合进 Linux 内核的新一代 VPN 协议，以其极简的代码库、极高的性能和先进的加密技术著称。相比传统的 OpenVPN 或 IPsec，WireGuard 在搬瓦工（BandwagonHost）VPS 上能提供更低的延迟和更高的吞吐量，非常适合作为个人的安全加密通道。  本文将手把手教你如何在 Ubuntu/Debian 系统上手动…”&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 极速安全：在搬瓦工 VPS 上部署 WireGuard (WG) 详细指南 =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WireGuard&#039;&#039;&#039; 是被整合进 Linux 内核的新一代 VPN 协议，以其极简的代码库、极高的性能和先进的加密技术著称。相比传统的 OpenVPN 或 IPsec，WireGuard 在搬瓦工（BandwagonHost）VPS 上能提供更低的延迟和更高的吞吐量，非常适合作为个人的安全加密通道。&lt;br /&gt;
&lt;br /&gt;
本文将手把手教你如何在 Ubuntu/Debian 系统上手动部署 WireGuard 服务端，并配置客户端连接。&lt;br /&gt;
&lt;br /&gt;
== 准备工作 ==&lt;br /&gt;
&lt;br /&gt;
* 一台搬瓦工 VPS（推荐使用 &#039;&#039;&#039;Ubuntu 20.04/22.04&#039;&#039;&#039; 或 &#039;&#039;&#039;Debian 10/11&#039;&#039;&#039; 系统）。&lt;br /&gt;
* 确保已通过 SSH 连接到服务器 root 用户。&lt;br /&gt;
&lt;br /&gt;
== 第一步：安装 WireGuard ==&lt;br /&gt;
&lt;br /&gt;
得益于搬瓦工提供的 KVM 架构和较新的内核，安装 WireGuard 非常简单。&lt;br /&gt;
&lt;br /&gt;
在终端执行以下命令更新软件源并安装：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
apt update &amp;amp;&amp;amp; apt install -y wireguard qrencode&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &#039;&#039;注意：这里顺便安装了 &amp;lt;code&amp;gt;qrencode&amp;lt;/code&amp;gt;，后面用于生成手机扫描的二维码。&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== 第二步：生成密钥对 ==&lt;br /&gt;
&lt;br /&gt;
WireGuard 使用类似 SSH 的公钥/私钥体系。我们需要分别为“服务端”和“客户端”生成密钥。&lt;br /&gt;
&lt;br /&gt;
=== 1. 生成服务端密钥 ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd /etc/wireguard&lt;br /&gt;
umask 077&lt;br /&gt;
wg genkey | tee server_private.key | wg pubkey &amp;gt; server_public.key&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. 生成客户端密钥 ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
wg genkey | tee client_private.key | wg pubkey &amp;gt; client_public.key&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
现在目录下应该有4个文件。你可以用 &amp;lt;code&amp;gt;cat&amp;lt;/code&amp;gt; 命令查看并记录它们的内容（&#039;&#039;&#039;千万不要泄露私钥 Private Key&#039;&#039;&#039;）。&lt;br /&gt;
&lt;br /&gt;
== 第三步：配置服务端 ==&lt;br /&gt;
&lt;br /&gt;
创建并编辑 WireGuard 的主配置文件 &amp;lt;code&amp;gt;wg0.conf&amp;lt;/code&amp;gt;：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano /etc/wireguard/wg0.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
将以下内容粘贴进去（&#039;&#039;&#039;注意替换密钥部分&#039;&#039;&#039;）：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ini&amp;quot;&amp;gt;&lt;br /&gt;
[Interface]&lt;br /&gt;
# 服务端私钥 (server_private.key 的内容)&lt;br /&gt;
PrivateKey = &amp;lt;这里填入你的 server_private.key&amp;gt;&lt;br /&gt;
# 服务端内网 IP，一般保持默认&lt;br /&gt;
Address = 10.0.0.1/24&lt;br /&gt;
# 监听端口 (UDP)，如果被防火墙拦截可尝试修改&lt;br /&gt;
ListenPort = 51820&lt;br /&gt;
# 启动后执行的路由规则 (开启 NAT 转发)&lt;br /&gt;
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o eth0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE&lt;br /&gt;
# 关闭后清除路由规则&lt;br /&gt;
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o eth0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE&lt;br /&gt;
&lt;br /&gt;
[Peer]&lt;br /&gt;
# 客户端公钥 (client_public.key 的内容)&lt;br /&gt;
PublicKey = &amp;lt;这里填入你的 client_public.key&amp;gt;&lt;br /&gt;
# 允许该客户端使用的内网 IP&lt;br /&gt;
AllowedIPs = 10.0.0.2/32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;注意&#039;&#039;&#039;：如果你的网卡名称不是 &amp;lt;code&amp;gt;eth0&amp;lt;/code&amp;gt;（可以用 &amp;lt;code&amp;gt;ip a&amp;lt;/code&amp;gt; 查看），请将 PostUp/PostDown 中的 &amp;lt;code&amp;gt;eth0&amp;lt;/code&amp;gt; 替换为实际网卡名称（如 &amp;lt;code&amp;gt;ens3&amp;lt;/code&amp;gt;）。&lt;br /&gt;
&lt;br /&gt;
== 第四步：开启 IP 转发 ==&lt;br /&gt;
&lt;br /&gt;
为了让 VPS 能转发流量，必须开启内核 IP 转发功能。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;net.ipv4.ip_forward=1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 第五步：启动服务 ==&lt;br /&gt;
&lt;br /&gt;
启动 WireGuard 并设置开机自启：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
wg-quick up wg0&lt;br /&gt;
systemctl enable wg-quick@wg0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
如果没有任何报错，输入 &amp;lt;code&amp;gt;wg&amp;lt;/code&amp;gt; 命令应该能看到接口状态。&lt;br /&gt;
&lt;br /&gt;
== 第六步：配置客户端 ==&lt;br /&gt;
&lt;br /&gt;
=== 选项 A：手机端 (iOS/Android) ===&lt;br /&gt;
这是最酷的一步！我们可以直接在终端生成配置并转为二维码。&lt;br /&gt;
&lt;br /&gt;
1. 创建客户端配置文件模板 &amp;lt;code&amp;gt;client.conf&amp;lt;/code&amp;gt;：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano /etc/wireguard/client.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. 填入以下内容：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ini&amp;quot;&amp;gt;&lt;br /&gt;
[Interface]&lt;br /&gt;
# 客户端私钥 (client_private.key 的内容)&lt;br /&gt;
PrivateKey = &amp;lt;这里填入你的 client_private.key&amp;gt;&lt;br /&gt;
Address = 10.0.0.2/24&lt;br /&gt;
DNS = 8.8.8.8&lt;br /&gt;
&lt;br /&gt;
[Peer]&lt;br /&gt;
# 服务端公钥 (server_public.key 的内容)&lt;br /&gt;
PublicKey = &amp;lt;这里填入你的 server_public.key&amp;gt;&lt;br /&gt;
# 服务端公网 IP : 端口&lt;br /&gt;
Endpoint = &amp;lt;你的VPS公网IP&amp;gt;:51820&lt;br /&gt;
# 路由流量：0.0.0.0/0 代表代理所有流量&lt;br /&gt;
AllowedIPs = 0.0.0.0/0&lt;br /&gt;
# 保持连接心跳，防止 NAT 断连&lt;br /&gt;
PersistentKeepalive = 25&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. 生成二维码：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
qrencode -t ansiutf8 &amp;lt; client.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
此时你的 SSH 终端里会直接显示一个巨大的二维码，打开手机 WireGuard APP 扫描即可连接！&lt;br /&gt;
&lt;br /&gt;
=== 选项 B：电脑端 (Windows/macOS) ===&lt;br /&gt;
将上面的 &amp;lt;code&amp;gt;client.conf&amp;lt;/code&amp;gt; 内容复制，保存为 &amp;lt;code&amp;gt;wg0.conf&amp;lt;/code&amp;gt;，导入电脑版 WireGuard 客户端即可。&lt;br /&gt;
&lt;br /&gt;
== 常见问题排查 ==&lt;br /&gt;
&lt;br /&gt;
; Q: 连上了但无法上网？&lt;br /&gt;
: A: 检查 &#039;&#039;&#039;第四步&#039;&#039;&#039; 是否开启了 IP 转发。另外检查 VPS 的防火墙（UFW/IPTables）是否放行了 51820 UDP 端口。&lt;br /&gt;
: &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;ufw allow 51820/udp&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Q: 搬瓦工某些机房连不上？&lt;br /&gt;
: A: WireGuard 使用 UDP 协议，极少数地区的运营商可能会对大流量 UDP 进行 QOS 限速或阻断。如果遇到这种情况，可以尝试更换 ListenPort 端口，或者配合 udp2raw 使用（进阶玩法）。&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;Created by AlexLynn for md5.pw Community.&#039;&#039;&lt;br /&gt;
[[Category:500 常见应用指南 — Application Guides]]&lt;br /&gt;
[[Category:300 VPS 设置与管理 — VPS Setup and Management]]&lt;/div&gt;</summary>
		<author><name>AlexLynn</name></author>
	</entry>
	<entry>
		<id>https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5VPS%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96%EF%BC%9A%E5%8E%9F%E7%94%9FBBR%E5%BC%80%E5%90%AF%E6%8C%87%E5%8D%97&amp;diff=1055</id>
		<title>搬瓦工VPS性能优化：原生BBR开启指南</title>
		<link rel="alternate" type="text/html" href="https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5VPS%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96%EF%BC%9A%E5%8E%9F%E7%94%9FBBR%E5%BC%80%E5%90%AF%E6%8C%87%E5%8D%97&amp;diff=1055"/>
		<updated>2026-01-23T05:49:19Z</updated>

		<summary type="html">&lt;p&gt;AlexLynn：​&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 搬瓦工 VPS 性能飞跃：原生 BBR 拥塞控制开启与 TCP 协议栈优化指南 =&lt;br /&gt;
&lt;br /&gt;
很多用户在购买了搬瓦工（BandwagonHost）的高速线路（如 CN2 GIA 或 CMIN2）后，在晚高峰期间偶尔仍会感觉网络吞吐量波动。这通常不是线路问题，而是 Linux 默认的 TCP 拥塞控制算法（Cubic 或 Reno）在高丢包或高延迟环境下表现保守导致的。&lt;br /&gt;
&lt;br /&gt;
本文将指导你如何在不使用任何第三方“一键脚本”的情况下，安全地通过 Linux 原生命令开启 &#039;&#039;&#039;BBR (Bottleneck Bandwidth and Round-trip propagation time)&#039;&#039;&#039;，并进行 TCP 协议栈的微调，以榨干服务器的每一滴网络性能。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;警告&#039;&#039;&#039;：虽然本文操作均为系统原生命令，但在修改内核参数前，建议在 KiwiVM 后台对 VPS 进行&#039;&#039;&#039;快照备份（Snapshot）&#039;&#039;&#039;，以防万一。&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 什么是 BBR？为什么它能加速？ ==&lt;br /&gt;
&lt;br /&gt;
传统的 TCP 拥塞控制算法（如 Cubic）是基于“丢包”来判断网络拥堵的。一旦发现丢包，它就会剧烈降低发送速度。而在跨国网络环境中，丢包是常态，这导致带宽往往跑不满。&lt;br /&gt;
&lt;br /&gt;
Google 开发的 &#039;&#039;&#039;BBR&#039;&#039;&#039; 算法则是基于“带宽”和“延迟”来建模。它不把丢包当作拥塞信号，而是尽可能探测物理链路的最大带宽。简单来说：&#039;&#039;&#039;BBR 就像给你的数据包装上了智能导航，能在拥堵的网络公路上更激进地抢占车道。&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== 第一步：检查 Linux 内核版本 ==&lt;br /&gt;
&lt;br /&gt;
BBR 需要 Linux Kernel &#039;&#039;&#039;4.9&#039;&#039;&#039; 以上版本支持。搬瓦工目前的系统镜像（CentOS 7/8, Ubuntu 20.04/22.04, Debian 10/11）默认内核均已支持，通常无需更换内核。&lt;br /&gt;
&lt;br /&gt;
在终端输入以下命令查看内核版本：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
uname -r&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* 如果输出类似 &amp;lt;code&amp;gt;4.18.0-xxx&amp;lt;/code&amp;gt;、&amp;lt;code&amp;gt;5.4.0-xxx&amp;lt;/code&amp;gt; 或更高，说明内核符合要求。&lt;br /&gt;
* 如果输出是 &amp;lt;code&amp;gt;3.10.x&amp;lt;/code&amp;gt;（主要是老旧的 CentOS 7），建议先重装系统至 Debian 11 或 Ubuntu 22.04（推荐）。&lt;br /&gt;
&lt;br /&gt;
== 第二步：开启 BBR (无需安装任何脚本) ==&lt;br /&gt;
&lt;br /&gt;
我们拒绝使用来路不明的“暴力魔改 BBR 脚本”，因为它们可能会破坏系统库文件或植入后门。Linux 原生开启 BBR 只需要修改 &amp;lt;code&amp;gt;/etc/sysctl.conf&amp;lt;/code&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
=== 1. 开启 IP 转发和 BBR ===&lt;br /&gt;
&lt;br /&gt;
复制以下完整命令块并在终端执行：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 开启 IP 转发&lt;br /&gt;
echo &amp;quot;net.ipv4.ip_forward = 1&amp;quot; | sudo tee -a /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
# 设置队列算法为 fq (Fair Queuing)&lt;br /&gt;
echo &amp;quot;net.core.default_qdisc = fq&amp;quot; | sudo tee -a /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
# 设置拥塞控制算法为 bbr&lt;br /&gt;
echo &amp;quot;net.ipv4.tcp_congestion_control = bbr&amp;quot; | sudo tee -a /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. 使配置生效 ===&lt;br /&gt;
&lt;br /&gt;
执行以下命令让刚才的修改立即生效：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo sysctl -p&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 3. 验证是否开启成功 ===&lt;br /&gt;
&lt;br /&gt;
执行以下命令检查：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
lsmod | grep bbr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
如果输出中包含 &amp;lt;code&amp;gt;tcp_bbr&amp;lt;/code&amp;gt;（如下图所示），说明 BBR 模块已成功加载并运行。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tcp_bbr                20480  14&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 第三步：进阶 TCP 协议栈优化 (可选) ==&lt;br /&gt;
&lt;br /&gt;
开启 BBR 已经能解决 90% 的问题。如果你想进一步优化高并发场景下的表现（例如建站），可以添加以下参数。&lt;br /&gt;
&lt;br /&gt;
编辑配置文件：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
在文件末尾添加以下优化参数（请仔细阅读注释）：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ini&amp;quot;&amp;gt;&lt;br /&gt;
# 增加 TCP 缓冲区大小，提升大文件传输速度&lt;br /&gt;
net.core.rmem_max = 16777216&lt;br /&gt;
net.core.wmem_max = 16777216&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 16777216&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 16777216&lt;br /&gt;
&lt;br /&gt;
# 开启 TCP 窗口缩放 (Window Scaling)，现代网络必备&lt;br /&gt;
net.ipv4.tcp_window_scaling = 1&lt;br /&gt;
&lt;br /&gt;
# 开启 SYN Cookies，防止 SYN Flood 攻击&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 缩短 TCP 连接的保活时间 (Keepalive)，默认 7200 秒太长了&lt;br /&gt;
net.ipv4.tcp_keepalive_time = 600&lt;br /&gt;
net.ipv4.tcp_keepalive_intvl = 15&lt;br /&gt;
net.ipv4.tcp_keepalive_probes = 5&lt;br /&gt;
&lt;br /&gt;
# 允许更多的半连接，应对突发流量&lt;br /&gt;
net.ipv4.tcp_max_syn_backlog = 8192&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
保存并退出 (&amp;lt;code&amp;gt;Ctrl+O&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Enter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Ctrl+X&amp;lt;/code&amp;gt;)，然后再次执行 &amp;lt;code&amp;gt;sysctl -p&amp;lt;/code&amp;gt; 使其生效。&lt;br /&gt;
&lt;br /&gt;
== 常见问题 (FAQ) ==&lt;br /&gt;
&lt;br /&gt;
; Q: 网上说的“BBR Plus”、“BBR 魔改版”比原版更好吗？&lt;br /&gt;
: A: &#039;&#039;&#039;不推荐在生产环境使用。&#039;&#039;&#039; 魔改版通常是不仅修改了算法参数（极度激进，可能导致断流），还替换了非官方编译的内核。对于搬瓦工这种本身质量就很高的线路（CN2 GIA），原生 BBR 的稳定性与速度平衡是最好的。&lt;br /&gt;
&lt;br /&gt;
; Q: 我是 OpenVZ 架构的 VPS，能用吗？&lt;br /&gt;
: A: 不能。本文教程仅适用于 KVM 架构（搬瓦工目前在售的所有 VPS 均为 KVM）。OpenVZ 用户受限于宿主机内核，无法自行开启 BBR。&lt;br /&gt;
&lt;br /&gt;
; Q: 开启后速度反而变慢了？&lt;br /&gt;
: A: 极少数情况下，特定地区的 ISP可能会对长时间高发包的 UDP/TCP 连接进行 QOS 限制。如果发现变慢，只需将 &amp;lt;code&amp;gt;sysctl.conf&amp;lt;/code&amp;gt; 中的 &amp;lt;code&amp;gt;bbr&amp;lt;/code&amp;gt; 改回 &amp;lt;code&amp;gt;cubic&amp;lt;/code&amp;gt; 并执行 &amp;lt;code&amp;gt;sysctl -p&amp;lt;/code&amp;gt; 即可复原。&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;Created by AlexLynn for md5.pw Community.&#039;&#039;&lt;br /&gt;
[[Category:300 VPS 设置与管理 — VPS Setup and Management]]&lt;br /&gt;
[[Category:500 常见应用指南 — Application Guides]]&lt;/div&gt;</summary>
		<author><name>AlexLynn</name></author>
	</entry>
	<entry>
		<id>https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5VPS%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96%EF%BC%9A%E5%8E%9F%E7%94%9FBBR%E5%BC%80%E5%90%AF%E6%8C%87%E5%8D%97&amp;diff=1054</id>
		<title>搬瓦工VPS性能优化：原生BBR开启指南</title>
		<link rel="alternate" type="text/html" href="https://md5.pw/index.php?title=%E6%90%AC%E7%93%A6%E5%B7%A5VPS%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96%EF%BC%9A%E5%8E%9F%E7%94%9FBBR%E5%BC%80%E5%90%AF%E6%8C%87%E5%8D%97&amp;diff=1054"/>
		<updated>2026-01-23T05:36:27Z</updated>

		<summary type="html">&lt;p&gt;AlexLynn：​创建页面，内容为“= 搬瓦工 VPS 性能飞跃：原生 BBR 拥塞控制开启与 TCP 协议栈优化指南 =  很多用户在购买了搬瓦工（BandwagonHost）的高速线路（如 CN2 GIA 或 CMIN2）后，在晚高峰期间偶尔仍会感觉网络吞吐量波动。这通常不是线路问题，而是 Linux 默认的 TCP 拥塞控制算法（Cubic 或 Reno）在高丢包或高延迟环境下表现保守导致的。  本文将指导你如何在不使用任何第三方“一…”&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 搬瓦工 VPS 性能飞跃：原生 BBR 拥塞控制开启与 TCP 协议栈优化指南 =&lt;br /&gt;
&lt;br /&gt;
很多用户在购买了搬瓦工（BandwagonHost）的高速线路（如 CN2 GIA 或 CMIN2）后，在晚高峰期间偶尔仍会感觉网络吞吐量波动。这通常不是线路问题，而是 Linux 默认的 TCP 拥塞控制算法（Cubic 或 Reno）在高丢包或高延迟环境下表现保守导致的。&lt;br /&gt;
&lt;br /&gt;
本文将指导你如何在不使用任何第三方“一键脚本”的情况下，安全地通过 Linux 原生命令开启 &#039;&#039;&#039;BBR (Bottleneck Bandwidth and Round-trip propagation time)&#039;&#039;&#039;，并进行 TCP 协议栈的微调，以榨干服务器的每一滴网络性能。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;警告&#039;&#039;&#039;：虽然本文操作均为系统原生命令，但在修改内核参数前，建议在 KiwiVM 后台对 VPS 进行&#039;&#039;&#039;快照备份（Snapshot）&#039;&#039;&#039;，以防万一。&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 什么是 BBR？为什么它能加速？ ==&lt;br /&gt;
&lt;br /&gt;
传统的 TCP 拥塞控制算法（如 Cubic）是基于“丢包”来判断网络拥堵的。一旦发现丢包，它就会剧烈降低发送速度。而在跨国网络环境中，丢包是常态，这导致带宽往往跑不满。&lt;br /&gt;
&lt;br /&gt;
Google 开发的 &#039;&#039;&#039;BBR&#039;&#039;&#039; 算法则是基于“带宽”和“延迟”来建模。它不把丢包当作拥塞信号，而是尽可能探测物理链路的最大带宽。简单来说：&#039;&#039;&#039;BBR 就像给你的数据包装上了智能导航，能在拥堵的网络公路上更激进地抢占车道。&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== 第一步：检查 Linux 内核版本 ==&lt;br /&gt;
&lt;br /&gt;
BBR 需要 Linux Kernel &#039;&#039;&#039;4.9&#039;&#039;&#039; 以上版本支持。搬瓦工目前的系统镜像（CentOS 7/8, Ubuntu 20.04/22.04, Debian 10/11）默认内核均已支持，通常无需更换内核。&lt;br /&gt;
&lt;br /&gt;
在终端输入以下命令查看内核版本：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
uname -r&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* 如果输出类似 &amp;lt;code&amp;gt;4.18.0-xxx&amp;lt;/code&amp;gt;、&amp;lt;code&amp;gt;5.4.0-xxx&amp;lt;/code&amp;gt; 或更高，说明内核符合要求。&lt;br /&gt;
* 如果输出是 &amp;lt;code&amp;gt;3.10.x&amp;lt;/code&amp;gt;（主要是老旧的 CentOS 7），建议先重装系统至 Debian 11 或 Ubuntu 22.04（推荐）。&lt;br /&gt;
&lt;br /&gt;
== 第二步：开启 BBR (无需安装任何脚本) ==&lt;br /&gt;
&lt;br /&gt;
我们拒绝使用来路不明的“暴力魔改 BBR 脚本”，因为它们可能会破坏系统库文件或植入后门。Linux 原生开启 BBR 只需要修改 &amp;lt;code&amp;gt;/etc/sysctl.conf&amp;lt;/code&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
=== 1. 开启 IP 转发和 BBR ===&lt;br /&gt;
&lt;br /&gt;
复制以下完整命令块并在终端执行：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 开启 IP 转发&lt;br /&gt;
echo &amp;quot;net.ipv4.ip_forward = 1&amp;quot; | sudo tee -a /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
# 设置队列算法为 fq (Fair Queuing)&lt;br /&gt;
echo &amp;quot;net.core.default_qdisc = fq&amp;quot; | sudo tee -a /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
# 设置拥塞控制算法为 bbr&lt;br /&gt;
echo &amp;quot;net.ipv4.tcp_congestion_control = bbr&amp;quot; | sudo tee -a /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. 使配置生效 ===&lt;br /&gt;
&lt;br /&gt;
执行以下命令让刚才的修改立即生效：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo sysctl -p&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 3. 验证是否开启成功 ===&lt;br /&gt;
&lt;br /&gt;
执行以下命令检查：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
lsmod | grep bbr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
如果输出中包含 &amp;lt;code&amp;gt;tcp_bbr&amp;lt;/code&amp;gt;（如下图所示），说明 BBR 模块已成功加载并运行。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tcp_bbr                20480  14&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 第三步：进阶 TCP 协议栈优化 (可选) ==&lt;br /&gt;
&lt;br /&gt;
开启 BBR 已经能解决 90% 的问题。如果你想进一步优化高并发场景下的表现（例如建站），可以添加以下参数。&lt;br /&gt;
&lt;br /&gt;
编辑配置文件：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
在文件末尾添加以下优化参数（请仔细阅读注释）：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ini&amp;quot;&amp;gt;&lt;br /&gt;
# 增加 TCP 缓冲区大小，提升大文件传输速度&lt;br /&gt;
net.core.rmem_max = 16777216&lt;br /&gt;
net.core.wmem_max = 16777216&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 16777216&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 16777216&lt;br /&gt;
&lt;br /&gt;
# 开启 TCP 窗口缩放 (Window Scaling)，现代网络必备&lt;br /&gt;
net.ipv4.tcp_window_scaling = 1&lt;br /&gt;
&lt;br /&gt;
# 开启 SYN Cookies，防止 SYN Flood 攻击&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 缩短 TCP 连接的保活时间 (Keepalive)，默认 7200 秒太长了&lt;br /&gt;
net.ipv4.tcp_keepalive_time = 600&lt;br /&gt;
net.ipv4.tcp_keepalive_intvl = 15&lt;br /&gt;
net.ipv4.tcp_keepalive_probes = 5&lt;br /&gt;
&lt;br /&gt;
# 允许更多的半连接，应对突发流量&lt;br /&gt;
net.ipv4.tcp_max_syn_backlog = 8192&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
保存并退出 (&amp;lt;code&amp;gt;Ctrl+O&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Enter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Ctrl+X&amp;lt;/code&amp;gt;)，然后再次执行 &amp;lt;code&amp;gt;sysctl -p&amp;lt;/code&amp;gt; 使其生效。&lt;br /&gt;
&lt;br /&gt;
== 常见问题 (FAQ) ==&lt;br /&gt;
&lt;br /&gt;
; Q: 网上说的“BBR Plus”、“BBR 魔改版”比原版更好吗？&lt;br /&gt;
: A: &#039;&#039;&#039;不推荐在生产环境使用。&#039;&#039;&#039; 魔改版通常是不仅修改了算法参数（极度激进，可能导致断流），还替换了非官方编译的内核。对于搬瓦工这种本身质量就很高的线路（CN2 GIA），原生 BBR 的稳定性与速度平衡是最好的。&lt;br /&gt;
&lt;br /&gt;
; Q: 我是 OpenVZ 架构的 VPS，能用吗？&lt;br /&gt;
: A: 不能。本文教程仅适用于 KVM 架构（搬瓦工目前在售的所有 VPS 均为 KVM）。OpenVZ 用户受限于宿主机内核，无法自行开启 BBR。&lt;br /&gt;
&lt;br /&gt;
; Q: 开启后速度反而变慢了？&lt;br /&gt;
: A: 极少数情况下，特定地区的 ISP可能会对长时间高发包的 UDP/TCP 连接进行 QOS 限制。如果发现变慢，只需将 &amp;lt;code&amp;gt;sysctl.conf&amp;lt;/code&amp;gt; 中的 &amp;lt;code&amp;gt;bbr&amp;lt;/code&amp;gt; 改回 &amp;lt;code&amp;gt;cubic&amp;lt;/code&amp;gt; 并执行 &amp;lt;code&amp;gt;sysctl -p&amp;lt;/code&amp;gt; 即可复原。&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;Created by AlexLynn for md5.pw Community.&#039;&#039;&lt;br /&gt;
[[Category:500 常见应用指南]]&lt;br /&gt;
[[Category:300 VPS 设置与管理]]&lt;/div&gt;</summary>
		<author><name>AlexLynn</name></author>
	</entry>
</feed>