zh

Trojan VPS配置:隐蔽代理协议完整指南

Trojan是一种将代理流量完全伪装成正常HTTPS流量的代理协议。其设计理念是:如果代理流量在协议层面与真实HTTPS无法区分,防火墙就无法基于协议特征进行封锁。Trojan服务器在443端口上同时运行一个真实网站,当检测到无效的Trojan请求时,会将连接转发给后端Web服务器,呈现出完整的网站响应,使针对服务器的主动探测无效。

Need this done for your project?

We implement, you ship. Async, documented, done in days.

Start a Brief

前置条件:域名和TLS证书

Trojan需要有效的域名和TLS证书。首先将域名A记录指向VPS IP,然后申请Let's Encrypt证书:
apt install -y certbot
certbot certonly --standalone -d yourdomain.com --email [email protected] --agree-tos -n
证书文件保存在「/etc/letsencrypt/live/yourdomain.com/」目录。证书有效期90天,certbot会自动续期。 安装Trojan(推荐trojan-go版本,功能更丰富):
wget https://github.com/p4gefau1t/trojan-go/releases/latest/download/trojan-go-linux-amd64.zip
unzip trojan-go-linux-amd64.zip -d /usr/local/bin/

Trojan服务端配置

创建「/etc/trojan-go/config.json」:
{
  "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/letsencrypt/live/yourdomain.com/fullchain.pem",
    "key": "/etc/letsencrypt/live/yourdomain.com/privkey.pem",
    "sni": "yourdomain.com"
  },
  "router": {
    "enabled": true,
    "bypass": ["geoip:cn", "geosite:cn"],
    "proxy": ["default"]
  }
}
「remote_addr/port」是后端伪装网站的地址。当防火墙或审查机构主动向443端口发送探测请求时,Trojan会将其转发到Nginx后端,返回正常网站内容,使服务器看起来只是一个普通的HTTPS网站。
systemctl enable --now trojan-go

配置后端伪装网站

需要在80端口配置一个真实可用的网站作为伪装:
apt install -y nginx
# 创建简单的静态网站
echo "Welcome" > /var/www/html/index.html
systemctl enable --now nginx
Nginx监听80端口(HTTP),Trojan监听443端口(HTTPS)。当收到非Trojan请求时,Trojan会回落到80端口,呈现出正常的网站。 客户端配置:服务器地址、端口443、密码、域名(用于SNI验证)、开启TLS并跳过证书验证(如果使用IP直连)。 推荐客户端:Clash(多平台)、Trojan-Qt5、v2rayN(Windows)、NekoBox(Android)。Clash支持同时配置多个协议节点,可在Shadowsocks、Trojan、VMess之间自动切换,是多节点管理的最佳选择。

Why Anubiz Host

100% async — no calls, no meetings
Delivered in days, not weeks
Full documentation included
Production-grade from day one
Security-first approach
Post-delivery support included

Ready to get started?

Skip the research. Tell us what you need, and we'll scope it, implement it, and hand it back — fully documented and production-ready.

Anubiz Chat AI

Online