v2ray攻略

环境准备


# 下载v2ray-core源码
git clone https://github.com/v2ray/v2ray-core.git

# 进入源码目录后编译v2ray
cd v2ray-core/main
env CGO_ENABLED=0 go build -o /usr/bin/v2ray -ldflags "-s -w"

设置service

cat <<'EOF'>/etc/systemd/system/v2ray.service
[Unit]
After=network.target nss-lookup.target
Wants=network-online.target

[Service]
Type=simple
User=root
ExecStart=/usr/bin/v2ray -config /etc/v2ray/config.json
Restart=on-failure
RestartPreventExitStatus=23

[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable v2ray
systemctl start v2ray

核心配置


mkdir -p /etc/v2ray
cat <<'EOF'>/etc/v2ray/config.json
{
  "port": 443,
  "protocol": "vmess",
  "settings": {
    "clients": [{
      "id": "自行生成 UUID",
      "alterId": 64
     }]
  },
  "streamSettings": {
    "network":"ws",
    "security": "tls",
    "wsSettings":{
      "path":"/",
      "headers":{}
    },
    "tlsSettings": {
      "serverName": "填写域名,如:xxx.com",
      "certificates": [{
        "certificateFile": "公钥文件绝对路径,如:/path/to/xxx.com.crt",
        "keyFile": "私钥文件绝对路径,如:/path/to/xxx.com.key"
      }]
    }
  }
}
EOF

FAQ

Loading Disqus comments...
Table of Contents