服务端

Xray + Reality + VLESS + Docker 的方案

docker-compose.yaml

使用官方原版镜像ghcr.io/xtls/xray-core:26.3.27

services:
  xray-core:
    image: ghcr.io/xtls/xray-core:26.3.27
    container_name: xray-core
    restart: unless-stopped
    network_mode: host ##性能好
    volumes:
      - ./config.json:/etc/xray/config.json

    command: ["run", "-c", "/etc/xray/config.json"]

config.json

{
  "inbounds": [
    {
      "port": 443,
      "protocol": "vless",
      "settings": {
        "clients": [
          {
            "id": "修改为你的UUID",
            "flow": "xtls-rprx-vision"
          }
        ],
        "decryption": "none"
      },
      "streamSettings": {
        "network": "tcp",
        "security": "reality",
        "realitySettings": {
          "show": false,
          "dest": "www.cloudflare.com:443",
          "xver": 0,
          "serverNames": [
            "www.cloudflare.com"
          ],
          "privateKey": "修改为你的PrivateKey",
          "shortIds": [
            "12345678"
          ]
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom"
    }
  ]
}

需要修改的内容:

  • port: 修改为服务端开放的端口,默认是```443``
  • uuid(clients.id): docker run --rm ghcr.io/xtls/xray-core:26.3.27 uuid 生成UUID,或者 cat /proc/sys/kernel/random/uuid
  • privateKey: docker run --rm ghcr.io/xtls/xray-core:26.3.27 x25519 生成公私钥, 结果如下:
PrivateKey: xxxxx
Password (PublicKey): xxxxx
Hash32: xxxxx

PrivateKey私钥配置在服务端,Password (PublicKey)公钥配置在客户端

  • shortIds: 客户端要保持一致

客户端

使用 v2rayN 最新版本, 选择 配置项-->添加[VLESS] 1.png

2.jpg

3.jpg