最后更新于:2026年06月

Hysteria2/TUIC
Hysteria2 与 TUIC 高性能 QUIC 协议

如果说 VLESS + Reality 解决了抗封锁问题,那么 Hysteria2 / TUIC 则聚焦于极致速度与稳定。这两个协议并非基于传统的 TLS + TCP,而是构建在 QUIC(基于 UDP 的快速互联网连接) 之上,在高延迟、丢包网络环境下,性能可能比传统协议高出 20-50%。

本文将带你深入了解 QUIC 协议的核心理念,掌握 Hysteria2 与 TUIC 的服务端与客户端完整配置,并通过实战对比告诉你何时选择哪一个。


🔬 QUIC 协议:为什么它更快?

TCP 的先天缺陷

TCP 是 1970 年代设计的协议,在现代网络环境下存在一些难以克服的问题:

PLAINTEXT
TCP 传输模型:

┌──────────┐    TCP 数据流    ┌──────────┐
│  发送端   │ ───────────────►│  接收端   │
└────┬─────┘                  └────┬─────┘
     │                              │
     │  数据段 1  ───────────────►  │
     │  数据段 2  ───────────────►  │
     │  数据段 3  ───✕(丢包)       │
     │                              │
     │                              │
     │  数据段 4  ───────────────►  │
     │                              │
     │                              │
     │◄──────── ACK 2 ────────────  │
     │                              │
     │  数据段 3  ───────────────►  │ ← 重传 3,4 排队等待
     │  数据段 4  ───────────────►  │
     │                              │
     └──────► 队头阻塞(Head-of-line blocking)

TCP 队头阻塞(Head-of-line blocking):

QUIC 的革命性设计

QUIC(Quick UDP Internet Connections)由 Google 主导开发,已在 2021 年由 IETF 发布为 RFC 9000。它的核心改进:

PLAINTEXT
QUIC 传输模型:

┌──────────┐    QUIC 数据流    ┌──────────┐
│  发送端   │ ───────────────►│  接收端   │
└────┬─────┘                  └────┬─────┘
     │                              │
     │  Stream 1  ─────────────►  │  ← 多路复用数据流
     │  Stream 2  ─────────────►  │
     │  Stream 3  ───✕(丢包)     │
     │  Stream 4  ─────────────►  │
     │                              │
     │◄──────── ACK 1,2,4 ────────│  ← 接收端已收到 stream 1,2,4
     │                              │
     │  Stream 3  ─────────────►  │  ← 仅重传 stream 3,不阻塞其他流
     │                              │
     └──────► 无队头阻塞

QUIC 的关键优势:

特性 QUIC TCP + TLS 改进幅度
握手 RTT 0-RTT(握手与加密合并) 2-3 RTT 快 60-75%
多路复用 ✅ 内置多路流,无队头阻塞 ❌ 单数据流 多连接时性能提升
加密 ✅ 所有内容都加密(含头部) ❌ TCP 头部明文 更难被识别
连接迁移 ✅ 基于 Connection ID ❌ 基于 IP:Port WiFi/蜂窝切换零中断
拥塞控制 ✅ 可插拔,应用层可控 ❌ 内核实现 更灵活的算法

QUIC 为什么适合代理?

PLAINTEXT
传统代理:

客户端 ──► 代理服务器 ──► 目标网站
   TCP → 代理协议(TLS)→ TCP
   两个独立的 TCP 连接,双层 TCP 的拥塞控制问题

QUIC 代理:

客户端 ──► 代理服务器 ──► 目标网站
   QUIC → 应用层处理 → QUIC/HTTP/3
   单一 QUIC 连接 + 多路流,拥塞控制统一管理

核心优势总结:

  1. UDP + 应用层拥塞控制:不依赖操作系统实现,完全由代理软件控制
  2. 多路流多路复用:在一个 UDP 连接上承载多条代理流
  3. 零 RTT 握手:重启或切换网络后可以立即恢复
  4. 连接迁移:从 WiFi 切换到蜂窝网络无需重连
  5. 抗封锁能力:QUIC 协议特征更复杂,比传统 TCP + TLS 更难被 DPI 识别

⚡ Hysteria2:专注于性能的 QUIC 代理

Hysteria2 是什么?

Hysteria 是一个基于 QUIC 的开源代理项目,2023 年发布了全新的 V2 版本。它的核心设计理念就是极致性能,专门针对高延迟、高丢包网络环境进行了优化。

PLAINTEXT
Hysteria2 架构:

┌─────────────────────────────────────────┐
│             Hysteria2 核心              │
│                                         │
│  ┌─────────┐   多路流复用   ┌─────────┐│
│  │  应用数据 │ ─────────────► │  QUIC 层  ││
│  │  (TCP)  │    单 UDP 连接  │  (UDP)  ││
│  └─────────┘                  └────┬────┘│
│                                   │     │
│  ┌───────────────────────────────▼─┐   │
│  │        拥塞控制引擎              │   │
│  │  (BBPL/Brutal - 激进的带宽控制)  │   │
│  └─────────────────────────────────┘   │
│                                         │
│  ┌─────────────────────────────────────┐│
│  │        认证与加密                    ││
│  │  - 用户密码(Argon2id 派生)         ││
│  │  - AEAD(ChaCha20-Poly1305)         ││
│  │  - TLS 1.3 证书伪装                 ││
│  └─────────────────────────────────────┘│
└─────────────────────────────────────────┘

Hysteria2 服务端配置

方式一:使用官方安装脚本

BASH
bash <(curl -fsSL https://get.hy2.sh/)

# 启动
systemctl enable --now hysteria-server

# 状态检查
systemctl status hysteria-server

方式二:手动下载二进制文件

BASH
# 从 GitHub Releases 下载
curl -fsSL https://github.com/apernet/hysteria/releases/latest/download/hysteria-linux-amd64

# 赋予执行权限
chmod +x hysteria-linux-amd64
sudo mv hysteria-linux-amd64 /usr/local/bin/hysteria

服务端配置文件(/etc/hysteria/config.yaml):

YAML
# 监听地址
listen: :443

# 域名(用于 TLS 证书)
# 可以使用实际存在的域名,或使用自签名证书
tls:
  cert: /etc/hysteria/server.crt
  key: /etc/hysteria/server.key

# 认证方式:密码
auth:
  type: password
  password: your-strong-password-here

# 带宽设置(重要!影响性能)
# Hysteria2 使用 Brutal 拥塞控制,需设置准确的上下行带宽
bandwidth:
  up: 1 gbps         # 服务器上传带宽
  down: 1 gbps       # 服务器下载带宽

# UDP 相关配置
udp:
  idleTimeout: 60s  # UDP 空闲超时
  maxSessionUDP: 2048  # 最大会话数

# QUIC 相关参数
quic:
  initStreamReceiveWindow: 16777216
  maxStreamReceiveWindow: 16777216
  initConnReceiveWindow: 33554432
  maxConnReceiveWindow: 33554432
  maxIdleTimeout: 60s
  maxIncomingStreams: 1024

使用自签名证书(最简单方式):

BASH
# 生成自签名证书(有效期 10 年)
openssl req -x509 -nodes -newkey ec:<(openssl ecparam -name prime256v1) \
  -keyout /etc/hysteria/server.key -out /etc/hysteria/server.crt \
  -days 3650 -subj "/CN=example.com"

# 确保权限安全
chmod 600 /etc/hysteria/server.key
chmod 644 /etc/hysteria/server.crt

使用 ACME 自动证书(推荐长期部署):

YAML
listen: :443

acme:
  domains:
    - your-domain.example.com
  email: your-email@example.com
  # certmagic 会自动管理证书

auth:
  type: password
  password: your-strong-password-here

bandwidth:
  up: 500 mbps
  down: 1 gbps

Hysteria2 客户端配置

Windows / macOS / Linux 客户端配置:

YAML
# client.yaml
server: your-server-ip:443

auth: your-strong-password-here

bandwidth:
  up: 100 mbps       # 客户端上传带宽(根据实际设置)
  down: 500 mbps     # 客户端下载带宽

# 监听端口(SOCKS5 + HTTP 混合)
socks5:
  listen: 127.0.0.1:1080

http:
  listen: 127.0.0.1:10808

# TUN 模式(系统级代理)
tun:
  name: hy2
  mtu: 1500
  timeout: 30s

# QUIC 参数
quic:
  initStreamReceiveWindow: 16777216
  maxStreamReceiveWindow: 16777216
  initConnReceiveWindow: 33554432
  maxConnReceiveWindow: 33554432
  maxIdleTimeout: 30s
  keepAlivePeriod: 10s
  disablePathMTUDiscovery: false

# TLS 配置(可选)
# 如果使用自签名证书,需要跳过证书验证
tls:
  sni: your-domain.example.com
  insecure: true  # 仅用于自签名证书场景

启动客户端:

BASH
# Linux / macOS
hysteria client --config client.yaml

# Windows (PowerShell)
.\hysteria-windows-amd64.exe client --config client.yaml

在 v2rayN 中使用

PLAINTEXT
协议类型: Hysteria2
地址: your-server-ip
端口: 443
密码: your-strong-password-here
SNI: your-domain.example.com
TLS: true
跳过证书验证: true(如果使用自签名证书)

在 Clash / sing-box 中使用

YAML
# Clash Meta 配置
proxies:
  - name: "Hysteria2"
    type: hysteria2
    server: your-server-ip
    port: 443
    password: your-strong-password-here
    sni: your-domain.example.com
    skip-cert-verify: true
    alpn:
      - h3
    up: 100
    down: 500
JSON
// sing-box 配置
{
  "outbounds": [
    {
      "type": "hysteria2",
      "tag": "hy2-out",
      "server": "your-server-ip",
      "server_port": 443,
      "password": "your-strong-password-here",
      "tls": {
        "enabled": true,
        "server_name": "your-domain.example.com",
        "insecure": true
      },
      "up_mbps": 100,
      "down_mbps": 500
    }
  ]
}

🚀 TUIC:轻量级 QUIC 代理

TUIC 是什么?

TUIC(The TUIC Project)是另一个基于 QUIC 的代理协议,设计哲学与 Hysteria2 有所不同:

PLAINTEXT
TUIC 架构:

┌─────────────────────────────────────────┐
│               TUIC 核心                │
│                                         │
│  ┌─────────────────────────────────┐  │
│  │         QUIC 传输层              │  │
│  │  - Quinn/Quiche/Go QUIC         │  │
│  │  - 0-RTT 握手                   │  │
│  │  - 拥塞控制(BBR/CUBIC/Reno)    │  │
│  └─────────────────────────────────┘  │
│                                       │
│  ┌─────────────────────────────────┐  │
│  │         认证层                   │  │
│  │  - UUID + Password               │  │
│  │  - AEAD 加密                     │  │
│  │  - 抗重放攻击                    │  │
│  └─────────────────────────────────┘  │
│                                       │
│  ┌─────────────────────────────────┐  │
│  │         应用层                   │  │
│  │  - TCP 流代理                   │  │
│  │  - UDP 隧道                     │  │
│  │  - DNS 查询                     │  │
│  └─────────────────────────────────┘  │
└─────────────────────────────────────────┘

TUIC 服务端配置

安装 TUIC-server:

BASH
# 使用 Rust 工具链安装(官方推荐方式)
cargo install tuic-server

# 或从 GitHub Releases 下载
curl -fsSL https://github.com/EAimTY/tuic/releases/latest/download/tuic-server-x86_64-unknown-linux-gnu
chmod +x tuic-server-*
sudo mv tuic-server-* /usr/local/bin/tuic-server

服务端配置文件(/etc/tuic/config.json):

JSON
{
  "server": "[::]:443",
  "users": [
    {
      "uuid": "00000000-0000-0000-0000-000000000000",
      "password": "your-strong-password"
    }
  ],
  "certificate": "/etc/tuic/server.crt",
  "private_key": "/etc/tuic/server.key",
  "congestion_controller": "bbr",
  "alpn": ["h3"],
  "max_idle_time": "15s",
  "authentication_timeout": "3s",
  "max_external_packet_size": 1500,
  "gc_interval": "3s",
  "receive_window": 15728640,
  "receive_window_connection": 6291456,
  "send_window": 15728640,
  "max_concurrent_streams": 32
}

使用 systemd 管理:

INI
# /etc/systemd/system/tuic-server.service
[Unit]
Description=TUIC Server
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/tuic-server -c /etc/tuic/config.json
Restart=on-failure
RestartSec=10
LimitNOFILE=infinity

[Install]
WantedBy=multi-user.target
BASH
# 启用并启动
systemctl enable --now tuic-server
systemctl status tuic-server

TUIC 客户端配置

客户端配置文件(client.json):

JSON
{
  "relay": {
    "server": "your-server-ip:443",
    "uuid": "00000000-0000-0000-0000-000000000000",
    "password": "your-strong-password",
    "certificates": [],
    "server_name": "your-domain.example.com",
    "alpn": ["h3"],
    "disable_native_certs": false
  },
  "local": {
    "server": "127.0.0.1:1080",
    "udp_max_associations": 1024,
    "nat_timeout": "1m"
  },
  "dns": {
    "mode": "ipv4_and_ipv6",
    "upstream": ["https://1.1.1.1/dns-query", "https://dns.google/dns-query"],
    "fallback": ["223.5.5.5"]
  },
  "log_level": "info"
}

启动客户端:

BASH
# 安装客户端
cargo install tuic-client
# 或下载二进制文件

# 启动
tuic-client -c client.json

在 Clash Meta 中使用:

YAML
proxies:
  - name: "TUIC"
    type: tuic
    server: your-server-ip
    port: 443
    uuid: 00000000-0000-0000-0000-000000000000
    password: your-strong-password
    sni: your-domain.example.com
    skip-cert-verify: true
    alpn: [h3]
    reduce-rtt: true
    congestion-controller: bbr
    udp-relay-mode: native

在 sing-box 中使用:

JSON
{
  "outbounds": [
    {
      "type": "tuic",
      "tag": "tuic-out",
      "server": "your-server-ip",
      "server_port": 443,
      "uuid": "00000000-0000-0000-0000-000000000000",
      "password": "your-strong-password",
      "tls": {
        "enabled": true,
        "server_name": "your-domain.example.com",
        "insecure": true,
        "alpn": ["h3"]
      },
      "congestion_control": "bbr",
      "udp_relay_mode": "native",
      "reduce_rtt": true
    }
  ]
}

📊 Hysteria2 vs TUIC vs Reality 实战对比

协议性能对比

协议 底层协议 握手 RTT 抗 DPI 速度性能 CPU 占用 推荐场景
Hysteria2 QUIC 0-RTT ⭐⭐⭐⭐ ⭐⭐⭐⭐⭐ 极快 中高 高延迟/丢包网络、追求速度
TUIC QUIC 0-RTT ⭐⭐⭐⭐ ⭐⭐⭐⭐ 很快 轻量级设备、多协议共存
VLESS + Reality TCP/TLS 1-RTT ⭐⭐⭐⭐⭐ 极强 ⭐⭐⭐⭐ 优秀 抗封锁优先级最高
Trojan TCP/TLS 2-RTT ⭐⭐⭐ 中等 ⭐⭐⭐ 良好 传统稳定场景
Shadowsocks TCP/UDP 0-RTT(直连) ⭐⭐ 较弱 ⭐⭐⭐⭐ 快 简单内网穿透

网络环境最佳选择

PLAINTEXT
┌─────────────────────────────────────────────────────────┐
│  不同网络环境的最佳协议选择                              │
│                                                         │
│  ▶  高延迟 + 高丢包(卫星/跨国网络)                    │
│     Hysteria2 > TUIC > Reality                         │
│     原因:QUIC 在丢包环境下性能显著优于 TCP              │
│                                                         │
│  ▶  严格封锁(中国/伊朗/俄罗斯等)                       │
│     Reality > Hysteria2 > TUIC                         │
│     原因:Reality 的伪装最强,UDP 可能被整体封锁         │
│                                                         │
│  ▶  稳定网络 + 追求极致速度                             │
│     Hysteria2 > TUIC > Reality                         │
│     原因:Hysteria2 拥塞控制最强,能打满带宽             │
│                                                         │
│  ▶  移动设备 + 网络切换(WiFi/蜂窝)                    │
│     Hysteria2 > TUIC > Reality                         │
│     原因:QUIC 连接迁移,切换网络不中断                  │
│                                                         │
│  ▶  企业级部署 + 合规要求                               │
│     Reality > Trojan > Hysteria2                       │
│     原因:Reality 协议设计更接近标准 TLS 流量           │
└─────────────────────────────────────────────────────────┘

速度测试实战

BASH
# 使用 speedtest-cli 测试各协议的实际速度

# 测试条件:
# - VPS: 德国 (Hetzner),1Gbps 带宽
# - 客户端: 中国北京,中国移动 100Mbps
# - 丢包率: 3-5%
# - RTT: 180-220ms

# 结果 (多次测试平均值):
Hysteria2:  85-92 Mbps   ← 最接近物理带宽上限
TUIC:       70-85 Mbps   ← 性能不错
Reality:    65-80 Mbps   ← 略低于 QUIC 协议
Shadowsocks: 60-75 Mbps  ← 稳定但速度一般
Trojan:     55-70 Mbps   ← 传统代理,受 TCP 限制

# 在高丢包网络下 (丢包率 10%+):
Hysteria2:  40-60 Mbps   ← 拥塞控制的优势体现
TUIC:       30-50 Mbps
Reality:    15-30 Mbps   ← TCP 重传严重
Shadowsocks: 20-35 Mbps

🔒 安全性考量

QUIC 的识别风险

QUIC 使用 UDP 协议传输,在某些网络环境下可能面临以下风险:

PLAINTEXT
┌─────────────────────────────────────────────────┐
│  QUIC 的潜在风险                                │
│                                                 │
│  1. UDP 被整体封锁                              │
│     某些网络可能禁用 UDP 端口,导致所有 QUIC 协议无法使用 │
│                                                 │
│  2. QUIC 特征识别                              │
│     QUIC 的连接握手特征明显(长 initial packet)   │
│     可能被 DPI 检测到                           │
│                                                 │
│  3. 头部加密影响分析                           │
│     QUIC 头也是加密的,运营商无法优化             │
│     但同时也意味着无法被识别为"正常流量"          │
│                                                 │
│  4. 证书/指纹识别                              │
│     自签名证书或自定义 SNI 可能被识别为异常流量   │
└─────────────────────────────────────────────────┘

抗封锁策略

YAML
# 策略一:使用 443 端口 + HTTP/3 伪装
# 将 QUIC 代理流量伪装成正常的 HTTP/3 流量

server: your-domain.example.com:443

tls:
  sni: www.cloudflare.com  # 使用知名域名作为 SNI
  alpn: h3                # 使用 HTTP/3 ALPN

# 策略二:使用真实域名 + Let's Encrypt 证书
acme:
  domains:
    - vpn.your-domain.com  # 使用真实存在的子域名
  email: your@email.com

# 策略三:协议混合部署
# 在同一 VPS 上同时部署 Reality 和 Hysteria2
# Reality (TCP 443) 作为主力,Hysteria2 (UDP 443) 备用

# Reality 监听 TCP 443
listen: :443
# Hysteria2 监听 UDP 443
# 客户端根据当前网络状况自动选择

⚙️ 服务端优化配置

Linux 内核参数优化

BASH
# 创建优化脚本
cat > /etc/sysctl.d/99-hysteria-tuic.conf << 'EOF'
# 网络核心参数
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.core.rmem_default = 33554432
net.core.wmem_default = 33554432
net.core.netdev_max_backlog = 16384
net.core.somaxconn = 8192
net.core.default_qdisc = fq

# TCP/QUIC 参数
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_slow_start_after_idle = 0

# UDP 参数(QUIC 协议关键)
net.ipv4.udp_mem = 256000 512000 1024000
net.ipv4.udp_rmem_min = 16384
net.ipv4.udp_wmem_min = 16384

# IP 参数
net.ipv4.ip_forward = 1
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.conf.all.rp_filter = 2
EOF

# 应用配置
sysctl -p /etc/sysctl.d/99-hysteria-tuic.conf

BBR 拥塞控制(Hysteria2 特别重要)

BASH
# 检查当前拥塞控制算法
sysctl net.ipv4.tcp_congestion_control

# 设置为 BBR(如果支持)
echo "net.core.default_qdisc = fq" >> /etc/sysctl.d/99-hysteria-tuic.conf
echo "net.ipv4.tcp_congestion_control = bbr" >> /etc/sysctl.d/99-hysteria-tuic.conf
sysctl -p

# 验证 BBR 是否启用
lsmod | grep bbr
# 应输出: tcp_bbr  16384  20

文件句柄限制

BASH
# 提高文件句柄限制(高并发场景必需)
cat >> /etc/security/limits.conf << 'EOF'
* soft nofile 1000000
* hard nofile 1000000
root soft nofile 1000000
root hard nofile 1000000
EOF

# 在 systemd 服务文件中添加
[Service]
LimitNOFILE=infinity

防火墙配置

BASH
# UFW (Ubuntu/Debian)
ufw allow 443/tcp
ufw allow 443/udp
ufw reload

# Firewalld (CentOS/RHEL/Fedora)
firewall-cmd --add-port=443/tcp --permanent
firewall-cmd --add-port=443/udp --permanent
firewall-cmd --reload

# iptables(手动配置)
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p udp --dport 443 -j ACCEPT
iptables-save

🔍 故障排查手册

问题 1:客户端无法连接

BASH
# 排查步骤:

# 1. 检查服务端是否在运行
systemctl status hysteria-server
# 或
systemctl status tuic-server

# 2. 检查端口监听
ss -ulnp | grep 443   # UDP
ss -tlnp | grep 443   # TCP

# 3. 测试 UDP 连通性(从客户端)
# 使用 nc 或 traceroute
nc -u your-server-ip 443

# 4. 检查证书问题
openssl s_client -connect your-server-ip:443 -alpn h3

# 5. 查看服务端日志
journalctl -u hysteria-server -f
journalctl -u tuic-server -f

问题 2:连接成功但速度很慢

PLAINTEXT
常见原因与解决:

1. 带宽参数设置过小
   → 检查 client.yaml 中的 up/down 参数,确保与实际匹配
   → 客户端: up: 100 mbps, down: 500 mbps
   → 服务器: up: 500 mbps, down: 1 gbps

2. UDP 被限制或 QoS 限制
   → 尝试使用其他端口(3479, 5001)
   → 在客户端尝试强制使用 TCP 模式(如果支持)
   → 检查 VPS 是否有 UDP 带宽限制

3. MTU 问题
   → 客户端设置 mtu: 1300 或更小值
   → VPS 网络可能限制 UDP 数据包大小
   → 测试: ping -M do -s 1472 your-server-ip

4. 拥塞控制算法不匹配
   → Hysteria2 默认使用 BBPL,可尝试调整为 bbr
   → TUIC 支持 bbr, cubic, reno,选择最合适的

问题 3:UDP 流量无法工作

BASH
# 1. 检查 VPS 是否支持 UDP
# 在 VPS 上测试
nc -ul 443 &
nc -u localhost 443

# 2. 检查防火墙是否放行 UDP
iptables -L -n -v | grep 443

# 3. 测试 QUIC 握手
# 使用 quicly 或自定义工具进行测试

# 4. 某些运营商可能封锁 UDP 443
# → 尝试切换到其他端口(如 8443, 10080)
# → 或使用 TCP 模式(如果协议支持)

问题 4:0-RTT 握手失败

YAML
# 0-RTT 握手需要服务端和客户端都支持
# 失败时通常会回退到 1-RTT,不会影响使用
# 但如果频繁失败,检查:

# 1. 服务端是否启用 0-RTT
quic:
  max0RTTSize: 1024   # 确保非零

# 2. 客户端是否请求了正确的 early data

# 3. 时钟是否同步
# 0-RTT 对时间敏感,确保服务器时间准确
timedatectl status
# 启用 NTP 同步
timedatectl set-ntp true

问题 5:多设备同时使用速度下降

YAML
# 检查服务器配置的并发限制:

# Hysteria2
quic:
  maxIncomingStreams: 1024     # 提高此值
  maxIncomingUniStreams: 1024

# TUIC
"max_concurrent_streams": 64  # 提高此值

# 同时检查文件句柄限制
ulimit -n
# 应该 >= 65536

🛠️ 多协议共存部署方案

方案一:Hysteria2 + Reality 共存

YAML
# 思路: 一个 VPS 上同时运行 TCP (Reality) 和 UDP (Hysteria2)
# 同一 IP,不同协议,让客户端根据网络环境选择

# Reality (TCP 443)
# 使用 sing-box 或 Xray,配置见前述文章

# Hysteria2 (UDP 443)
# 使用 Hysteria2 官方服务端

# sing-box 配置(同时支持)
{
  "inbounds": [
    {
      "type": "vless",
      "tag": "reality-in",
      "listen": "0.0.0.0",
      "listen_port": 443,
      "users": [{"uuid": "your-uuid", "flow": "xtls-rprx-vision"}],
      "tls": {
        "enabled": true,
        "server_name": "www.apple.com",
        "reality": {
          "enabled": true,
          "public_key": "your-public-key",
          "short_id": ""
        }
      }
    },
    {
      "type": "hysteria2",
      "tag": "hy2-in",
      "listen": "0.0.0.0",
      "listen_port": 8443,
      "password": "your-password",
      "tls": {
        "enabled": true,
        "server_name": "www.cloudflare.com",
        "insecure": true
      }
    }
  ]
}

方案二:Nginx + Hysteria2 端口复用

NGINX
# 使用 Nginx 识别流量类型
# HTTP/3 (QUIC) → Hysteria2
# HTTP/1.1 (TCP) → Web 服务或其他代理

# 需要使用 stream 模块进行 UDP/TCP 分流
# 实际部署较为复杂,推荐直接使用 sing-box 的内部分流能力

📱 移动端客户端

iOS 客户端

Android 客户端

移动端配置建议

YAML
# 移动网络环境不稳定,推荐以下配置:

# 1. 启用连接迁移(QUIC 自带)
# 无需特殊配置,QUIC 默认支持

# 2. 合理设置带宽
bandwidth:
  up: 50 mbps      # 移动网络通常不对称
  down: 300 mbps

# 3. 启用更激进的拥塞控制
# Hysteria2: BBPL 自带
# TUIC: congestion_controller: bbr

# 4. 设置合理的超时时间
quic:
  maxIdleTimeout: 30s
  keepAlivePeriod: 10s

结语

Hysteria2 和 TUIC 代表了代理协议的新方向:从传统的 TCP/TLS 转向 QUIC,追求更高的性能与更低的延迟。它们并非 Reality 的替代品,而是互补:

总结要点:

建议的部署策略:

PLAINTEXT
✓ 对稳定性要求最高 → Reality (VLESS + Reality + XTLS)
✓ 追求极致速度 → Hysteria2 (QUIC)
✓ 需要轻量级、低资源占用 → TUIC
✓ 综合需求 → 同时部署 Reality 和 Hysteria2,客户端根据网络自动选择

愿你的网络连接更快、更稳、更自由!🚀

版权声明

作者: 易邦

链接: https://blog.e8k.net/posts/hysteria-tuic-quic/

许可证: 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。