一键脚本搭建 VLESS + Reality(443 端口)
之前折腾节点一直是手动配的,步骤多、容易漏。后来整理了一个一键脚本,跑完就能用,端口固定 443,协议是 VLESS + Reality。这里把过程和脚本记下来,方便以后重装机器的时候直接用。
适用环境
- 一台 VPS,Debian 或 Ubuntu 都行
- 有 root 权限
- 域名可选,Reality 不需要域名也能跑
- 防火墙放行 443 端口
脚本内容
把下面这段保存成 install.sh:
#!/usr/bin/env bash
set -e
# ===== 可修改参数 =====
PORT=443
UUID=$(cat /proc/sys/kernel/random/uuid)
SNI="www.microsoft.com"
DEST="www.microsoft.com:443"
# =====================
echo "开始安装..."
apt update
apt install -y curl unzip
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install
KEYS=$(/usr/local/bin/xray x25519)
PRIVATE_KEY=$(echo "$KEYS" | grep "Private" | awk '{print $3}')
PUBLIC_KEY=$(echo "$KEYS" | grep "Public" | awk '{print $3}')
cat > /usr/local/etc/xray/config.json <<EOF
{
"inbounds": [
{
"listen": "0.0.0.0",
"port": $PORT,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "$UUID",
"flow": "xtls-rprx-vision"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "tcp",
"security": "reality",
"realitySettings": {
"show": false,
"dest": "$DEST",
"xver": 0,
"serverNames": ["$SNI"],
"privateKey": "$PRIVATE_KEY",
"shortIds": [""]
}
}
}
],
"outbounds": [
{
"protocol": "freedom"
}
]
}
EOF
systemctl enable xray
systemctl restart xray
IP=$(curl -s4 ifconfig.me)
echo "=============================="
echo "地址: $IP"
echo "端口: $PORT"
echo "UUID: $UUID"
echo "流控: xtls-rprx-vision"
echo "SNI: $SNI"
echo "公钥: $PUBLIC_KEY"
echo "=============================="