Files
nyaterm/docs-site/docs/guide/tunnels-and-proxy.md
T
KangandClaude Opus 5 e18cb3902e docs: cut the template phrasing and the authoring notes
The migrated prose leaned on a small set of constructions and repeated them
until they stopped carrying information. Across ~3.7k lines the source had 78
uses of "适合", 63 of "如果你", and 34 contrastive "而不是" clauses, most of
them attached to bullet lists that restated the feature name.

What changed:
- Replaced the "适合场景 / 适合:" tail hanging off nearly every section with
  either a plain sentence or nothing. "适合" is now 0, "如果你" is 0, and the
  18 remaining "而不是" clauses each rule out an assumption a reader would
  actually make (a rejected password is not truncated; a font name is not a
  bundled file; a decoder panic must not exit silently).
- Removed the closing editorial lines that asserted significance without adding
  information ("这也是 NyaTerm 和普通多标签终端差异较大的地方"), and the
  meta-commentary where the docs explained their own conventions.
- Dropped the relative time anchors that were already going stale: "新的 SFTP
  后端", "较新的工作区", "现在可以", "Newer Agent workflows".
- Deleted the "如果你准备录制文档素材" passage, which told the reader how to
  stage screenshots for the docs rather than how to use the recorder.
- Removed seven `:::tip Screenshot suggestion` blocks that shipped only in the
  English pages. They were internal authoring notes and pointed at a
  /img/docs/ tree and scripts/demo-*.sh files that do not exist in this repo.
- Dropped "推荐的工作流组合", four permutations of features documented
  elsewhere, and gave the synchronized input group one home instead of the
  three partial copies it had across two pages.
- Rewrote the cloud-sync conflict choices to lead with what is lost, since
  "适合:你确认云端版本才是应该保留的版本" buried the fact that local
  unsynced changes are discarded.

Also closes the remaining English gaps found while doing this: selection and
bulk operations, content-fingerprint upload, two FAQ entries, and two
quick-start steps existed only in Chinese. Chinese and English now carry the
same heading count on every page.

Verified with `pnpm --dir docs-site build` (both locales) and by re-resolving
all 22 cross-page anchors against the generated heading ids.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-22 11:27:47 +08:00

3.8 KiB
Raw Blame History

代理、跳板机与隧道

NyaTerm 把网络相关能力分成三层:

  1. 代理:先解决“怎么连出去”
  2. 跳板机:再解决“通过哪台 SSH 主机中转”
  3. 隧道:最后解决“把端口流量映射到哪里”

这三者经常会出现在同一个真实场景里,但职责不同,分开理解更清楚。

代理

代理用于帮助 NyaTerm 建立到远端的网络连接。

当前支持:

  • SOCKS5
  • HTTP
  • ProxyCommand

每个代理配置可保存:

  • 名称
  • 协议
  • 主机
  • 端口
  • 用户名 / 密码
  • ProxyCommand 命令模板

ProxyCommand

ProxyCommand 用于复用已有的命令行代理或企业网关工具。NyaTerm 按 OpenSSH 风格替换命令模板中的占位符:

占位符 含义
%h 目标主机
%p 目标端口
%r 登录用户名
%% 字面量 %

示例:

nc -X connect -x jump.example.com:1080 %h %p

自定义网关、堡垒机命令或本地代理程序都可以保存为 ProxyCommand 配置,再在 SSH 连接高级区域中选择。

代理在网络面板中统一管理,之后可以在 SSH 连接的高级区域中直接选择。

用于办公网必须走代理、某些区域网络不允许直连,或需要统一维护一组出站网络配置的情况。

跳板机

跳板机是 SSH 专属能力。它的作用不是代替代理,而是使用一个已保存的 SSH 连接作为中转入口。

用于堡垒机、只允许内网访问的目标主机,以及多层 SSH 网络隔离。

在 SSH 连接高级区域中,你可以直接从已有 SSH 连接里选一个作为跳板机。NyaTerm 会检查跳板机链路:

  • 如果引用的跳板机不存在,会阻止保存或提示修正
  • 如果多个连接互相引用形成环路,会阻止该配置,避免连接时无限递归
  • 多层跳板应保持为清晰的单向链路,例如 本机 -> 堡垒机 -> 内网主机

隧道

NyaTerm 在网络面板中提供专门的隧道管理页,可把端口映射保存为可复用配置。

支持的隧道类型

  • 本地隧道(local)
  • 远程隧道(remote)
  • 动态隧道(dynamic / SOCKS5)

本地隧道

把本机监听端口转发到远端目标地址,用于:

  • 访问内网数据库
  • 打开只能在远端访问的 Web 控制台
  • 通过 SSH 安全转发服务端口

远程隧道

把远端监听端口映射回本地服务,用于:

  • 临时把本地服务暴露给远端环境
  • 做反向调试或联调

动态隧道

创建一个本地 SOCKS5 代理端口,用于:

  • 浏览器或工具临时走 SSH 动态代理
  • 需要快速建立一条“经 SSH 出站”的代理链路

隧道配置项

创建隧道时,通常会配置:

  • 隧道名称
  • 隧道类型
  • 关联的 SSH 连接
  • 监听端口
  • 目标主机 / 目标端口(动态隧道除外)
  • 是否仅绑定 127.0.0.1
  • 是否自动打开

只需本机访问时保持绑定 127.0.0.1。监听 0.0.0.0 会把转发端口暴露给同网段的其他主机。

网络面板中的日常操作

在网络面板中,你可以:

  • 新建 / 编辑 / 删除代理
  • 新建 / 编辑 / 删除隧道
  • 直接打开或关闭某条隧道
  • 查看某条隧道当前是否处于打开状态

代理和隧道都是持久化配置,不必每次重新敲命令。

典型组合示例

示例 1:代理 + SSH

  • 先在网络面板中保存一个 SOCKS5 代理
  • 再在 SSH 连接高级区域里选择这个代理
  • 用于必须走代理的办公网或跨区访问环境

示例 2:跳板机 + 目标主机

  • 先保存堡垒机连接
  • 再在业务主机连接里把堡垒机设为跳板机
  • 用于内网分层登录

示例 3:SSH + 本地隧道

  • 建立 SSH 连接
  • 保存一个本地隧道 localhost:15432 -> db.internal:5432
  • 之后本地工具即可通过 127.0.0.1:15432 访问数据库