安装 xray
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install
生成 uuid
xray uuid
输出示例:8653f110-61d8-4363-8c5c-1224fa1bc18b
生成 Reality 密钥对
# 生成 X25519 公私钥对
xray x25519
输出示例:
PrivateKey: CDQnBSjLb45viCBJTVt7n5ZmImy80NW7ovdlqRPi2k
Password (PublicKey): nZY-gSIXu1N6lxpxzodqf_hc08UQBEkqiLNN5hv8TQ
Hash32: VXqfOosY-X1NwQTfMx7Vfd3kxlRvvxJYM5Vrac9WNJU
**重要:请保存好这两个密钥!**
- Private key(私钥):配置在服务器端
- Password(原 Public Key -> 公钥):配置在客户端
生成 Short ID
# 生成 16 位十六进制 short_id
openssl rand -hex 8
输出示例:a7c581a4431eca74
- 编辑 Xray 配置文件 vim /usr/local/etc/xray/config.json
| |
启动服务
| |
输出示例:
Xray 26.3.27 (Xray, Penetrates Everything.) d2758a0 (go1.26.1 linux/amd64) A unified platform for anti-censorship. 2026/05/05 04:44:43.340031 [Info] infra/conf/serial: Reading config: &{Name:/usr/local/etc/xray/config.json Format:json} Configuration OK.
| |
客户端如何连接?
客户端推荐:
- Windows/Linux/macOS: v2rayN
- Android: v2rayNG
- iOS: Shadowrocket
在你的客户端中填入以下关键参数:
- 协议: VLESS
- 地址/IP: 你的 VPS 公网 IP
- 端口: 443
- UUID: 你生成的 UUID
- 流控 (Flow): xtls-rprx-vision
- 传输层安全 (TLS): REALITY
- SNI: www.microsoft.com (必须与服务端 dest 一致)
- PublicKey: 你生成的 Public Key (公钥)
- ShortId: 你在配置中写的 shortId
- 指纹 (Fingerprint): chrome 或 firefox
选择目标网站
Reality 需要一个目标网站(dest/target)来进行伪装。这个网站需要满足以下条件:
- ✅ 支持 TLS 1.3
- ✅ 支持 X25519 密钥交换
- ✅ 支持 HTTP/2(h2)
- ⭐️ 加分项:网站服务器物理距离和你的VPS近 (IP 相近)
- ⭐️ 加分项:网站支持 OCSP Stapling
- 选取方法参考:https://github.com/XTLS/Xray-core/issues/2005#issuecomment-1538294415