搭建 Reality 协议

搭建 Reality 协议#

Reality 协议是一种安全的、基于加密的 Web 代理协议,常用于科学上网、加密传输和自建网络节点。

本文将指导你在 Linux / Windows 系统上搭建 Reality 协议服务器,并配置客户端。


1. 准备环境#

  • 服务器:建议 Linux VPS,Ubuntu 22.04 或 Debian 11
  • 域名:已解析到服务器 IP
  • 证书:使用 TLS / HTTPS(Let’s Encrypt 推荐)
  • 端口:默认 443,可自定义

2. 安装 Xray 核心#

Reality 协议需要 Xray-core 支持:

# 下载最新 Xray
wget https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-64.zip
unzip Xray-linux-64.zip -d /usr/local/bin/xray
chmod +x /usr/local/bin/xray/xray
  • 验证安装:
xray version

配置服务器#

  • 创建配置文件 /usr/local/etc/xray/config.json
{
  "inbounds": [
    {
      "port": 443,
      "protocol": "vless",
      "settings": {
        "clients": [
          {
            "id": "your-uuid-here",
            "flow": "xtls-rprx-direct"
          }
        ],
        "decryption": "none"
      },
      "streamSettings": {
        "network": "tcp",
        "security": "reality",
        "realitySettings": {
          "fingerprint": "chrome",
          "publicKey": "server_public_key_here",
          "shortIds": ["shortid1"]
        }
      }
    }
  ],
  "outbounds": [
    { "protocol": "freedom", "settings": {} }
  ]
}
  • UUID:使用 uuidgen 生成

  • publicKey / shortIds:生成安全参数,客户端必须一致

配置客户端#

客户端支持 Reality 协议的工具:

  • V2RayN / V2RayNG(Windows / Android)

  • Qv2ray(跨平台) 配置示例:

协议:VLESS
地址:your-domain.com
端口:443
ID:与服务器 UUID 一致
传输协议:TCP
底层传输安全:Reality
服务器公钥:与服务器一致
短 ID:与服务器一致