新服务器部署了科学上网,记录一下

1. 安装v2ray

# 下载安装脚本并执行wget https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.shbash install-release.sh

2. 配置v2ray

编辑配置文件 /usr/local/etc/v2ray/config.json,以下为WebSocket + TLS的推荐配置(需配合Nginx反向代理):

{
  "inbounds": [{
    "port": 10086,
    "protocol": "vmess",
    "settings": {
      "clients": [{
        "id": "自行生成的UUID",  // 使用`uuidgen`生成
        "alterId": 0
      }]
    },
    "streamSettings": {
      "network": "ws",
      "wsSettings": {
        "path": "/ray"  // 自定义路径,需与Nginx配置一致
      }
    }
  }],
  "outbounds": [{
    "protocol": "freedom"
  }]
}

3. 启动v2ray服务

systemctl enable v2ray

systemctl start v2ray

4. 配置Nginx反向代理(通过宝塔面板)

在宝塔面板中打开网站对应的Nginx配置,添加以下反向代理规则:

location /ray {  # 路径与v2ray配置中的`path`一致
  proxy_pass http://127.0.0.1:10086;  # 端口与v2ray配置一致
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
  proxy_set_header Host $host;
}

重启Nginx服务。

5.检查服务状态

  • 直接部署:systemctl status v2ray
  • Docker部署:docker ps | grep v2ray

6.客户端配置
使用v2ray客户端(如V2RayN、Qv2ray),填入服务器IP/域名、端口、UUID及路径(WebSocket需填写path)。

7.测试连通性
通过在线工具(如https://www.itdog.cn/tcping/)验证端口是否开放,或使用客户端连接测试。

发表评论

您的邮箱地址不会被公开。