Trojan-Go 协议详解:TLS 伪装与抗封锁完整实战

•

Trojan-Go 是什么?

Trojan-Go 是对经典 Trojan 协议的 Go 语言重写版本,由 p4gefau1t 开发。它在保持 Trojan 核心设计理念(模拟正常 HTTPS 流量)的同时,增加了更多抗封锁特性:多路复用(Mux)、Websocket 传输、Shadowsocks 前置加密等。对于需要高隐匿性的用户来说,Trojan-Go 是目前最可靠的协议之一。

🚀 推荐资源

🔥 机场推荐 — 精选优质机场,支持 Trojan-Go 节点

📥 机场客户端下载 — Windows/Mac/Android/iOS 客户端合集

一、Trojan vs Trojan-Go 对比

对比维度 Trojan (原版) Trojan-Go
开发语言 C++ Go
多路复用 ❌ 不支持 ✅ 支持 (Mux)
Websocket ❌ 不支持 ✅ 支持 (WS)
Shadowsocks 前置 ❌ 不支持 ✅ 支持
传输层 TCP only TCP / WS / gRPC
性能 更高(C++) 略低(Go GC)
抗封锁 中等 强(多Transport支持)

二、服务端一键部署

方法一:官方脚本(推荐)

# 安装 Trojan-Go
curl -O https://raw.githubusercontent.com/p4gefau1t/trojan-go/master/install.sh
sudo bash install.sh

# 启动服务
systemctl start trojan-go
systemctl enable trojan-go
systemctl status trojan-go

方法二:Docker 部署

docker run -d   --name trojan-go   -v /etc/trojan-go:/etc/trojan-go   -p 443:443   --restart unless-stopped   p4gefau1t/trojan-go

三、服务端配置详解

{
  "run_type": "server",
  "local_addr": "0.0.0.0",
  "local_port": 443,
  "remote_addr": "127.0.0.1",
  "remote_port": 80,
  "password": [
    "your-strong-password"
  ],
  "ssl": {
    "cert": "/etc/trojan-go/fullchain.pem",
    "key": "/etc/trojan-go/privkey.pem",
    "sni": "your-domain.com",
    "alpn": ["http/1.1"],
    "reuse_session": true,
    "session_ticket": false,
    "plain_http_response": "",
    "fallbacks": [
      {"dest": 80}
    ]
  },
  "tcp": {
    "prefer_ipv4": false,
    "no_delay": true,
    "keep_alive": true,
    "reuse_port": false,
    "fast_open": false,
    "fast_open_qlen": 20
  },
  "mux": {
    "enabled": true,
    "concurrency": 8
  },
  "websocket": {
    "enabled": true,
    "path": "/ws",
    "hostname": "your-domain.com",
    "obfuscation_password": "",
    "double_tls": false,
    "vhost": "your-domain.com"
  }
}

四、Nginx 反向代理配置(推荐)

将 Trojan-Go 放在 Nginx 后面,可以让 443 端口同时提供 HTTPS 网站服务和代理服务,进一步降低被检测风险。

server {
    listen 80;
    server_name your-domain.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name your-domain.com;

    ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;

    # 正常网站内容(伪装用)
    location / {
        root /var/www/html;
        index index.html;
    }

    # Trojan-Go WebSocket 路径
    location /ws {
        proxy_redirect off;
        proxy_pass http://127.0.0.1:10086;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

五、客户端配置

Clash Meta 配置示例

proxies:
  - name: "Trojan-Go-节点"
    type: trojan
    server: your-domain.com
    port: 443
    password: "your-strong-password"
    sni: your-domain.com
    skip-cert-verify: false
    network: ws
    ws-opts:
      path: "/ws"
      headers:
        Host: your-domain.com
    udp: true

Sing-box 配置示例

{
  "inbounds": [
    {"type": "mixed", "listen": "127.0.0.1", "listen_port": 7890}
  ],
  "outbounds": [
    {
      "type": "trojan",
      "server": "your-domain.com",
      "server_port": 443,
      "password": "your-strong-password",
      "tls": {
        "enabled": true,
        "server_name": "your-domain.com",
        "utls": {"enabled": true, "fingerprint": "chrome"}
      },
      "transport": {
        "type": "websocket",
        "path": "/ws",
        "headers": {"Host": "your-domain.com"}
      }
    },
    {"type": "direct", "tag": "direct"}
  ]
}

六、性能优化

  • 启用 Mux 多路复用:减少 TCP 握手次数,提升并发性能
  • 调整 fallback 页面:配置一个真实的 HTTPS 网站,增强伪装效果
  • 使用 TLS 1.3:减少握手延迟,提升安全性
  • 开启 WS 压缩:对小流量场景有显著提速效果

七、常见问题 FAQ

Q: Trojan-Go 会被检测吗?

A: Trojan-Go 的设计目标是模拟正常 HTTPS 流量,使用合法 TLS 证书,被动检测极难识别。配合 Nginx 伪装 + Websocket 传输,抗封锁能力非常强。

Q: 443 端口被封怎么办?

A: 可以使用 Websocket (WS) 模式,将流量伪装成正常的 WebSocket 连接,或者使用 Shadowsocks 前置加密 进一步混淆。

Q: 如何选择 Trojan 还是 Trojan-Go?

A: 追求极致性能选原版 Trojan(C++);追求抗封锁能力和多传输方式选 Trojan-Go。

总结

Trojan-Go 是目前抗封锁能力最强的代理协议之一,通过 TLS 伪装 + Websocket + 多路复用,能有效绕过大部分深度包检测(DPI)。配合 优质机场 的 Trojan-Go 节点,无需自建即可享受高质量代理服务。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注