手搓xray

更新VPS命令:

sudo apt update && sudo apt upgrade -y

安装xray

bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install

以上命令来源(xray github页面):https://github.com/XTLS/Xray-install
file

进入/usr/local/etc/xray

vless+Reality(无证书)

打开xray.conf,清空所有内容

{
  "log": {
    "loglevel": "warning"
  },
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "rules": [
      {
        "type": "field",
        "port": "443",
        "network": "udp",
        "outboundTag": "block"
      },
      {
        "type": "field",
        "ip": [
          "geoip:cn",
          "geoip:private"
        ],
        "outboundTag": "block"
      }
    ]
  },
  "inbounds": [
    {
      "listen": "0.0.0.0",
      "port": 443,
      "protocol": "vless",
      "settings": {
        "clients": [
          {
            "id": "uuid",  //vps也是可以生成:uuidgen
            "flow": "xtls-rprx-vision"
          }
        ],
        "decryption": "none"
      },
      "streamSettings": {
        "network": "tcp",
        "security": "reality",
        "realitySettings": {
          "show": false,
          "dest": "www.lowes.com:443",   //可直连的网站
          "xver": 0,
          "serverNames": [
            "www.lowes.com"         //可直连的网站
          ],
          "privateKey": "YPNXH3pPot-sij1vw8y01_vSKUwhZIcbxb3U",   //这个vps生成,xray x25519,生成一对,服务器端和客户端
          "shortIds": [
            "6bfe1esdsa9356a"   //这个vps可生成,命令:openssl rand -hex 8
          ]
        }
      },
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls",
          "quic"
        ]
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "tag": "direct"
    },
    {
      "protocol": "blackhole",
      "tag": "block"
    }
  ],
  "policy": {
    "levels": {
      "0": {
        "handshake": 2,
        "connIdle": 120
      }
    }
  }
}

2/vless+TCP + TLS(需生成证书,圈叉可用)

{
    "log": {
        "loglevel": "warning"
    },
    "inbounds": [
        {
            "port": 443,  //可以改
            "protocol": "vless",
            "settings": {
                "clients": [
                    {
                        "id": "5 uuid  8e-a003-61ddb79f7238",  //uuid
                        "level": 0
                    }
                ],
                "decryption": "none"
            },
            "streamSettings": {
                "network": "tcp",
                "security": "tls",
                "tlsSettings": {
                    "alpn": ["h2","http/1.1"],
                    "certificates": [
                        {
                            "certificateFile": "/usr/local/etc/xray/self-sign.crt",  //在https://bkssl.com/ssl/selfsign 生成一对
                            "keyFile": "/usr/local/etc/xray/private.key"
                        }
                    ]
                }
            }
        }
    ],
    "outbounds": [
        {
            "protocol": "freedom"
        }
    ]
}

启动 Xray

systemctl start xray

开机自启

systemctl enable xray

重启 Xray(改了配置后用这个)

systemctl restart xray

查看运行状态

systemctl status xray

客户端设置
file
file