1、安装v2ray

运行安装脚本:

bash <(curl -L -s https://install.direct/go.sh)

收到错误提示,资源地址换了:

ERROR: This script has been DISCARDED, please switch to fhs-install-v2ray project.
HOW TO USE: https://github.com/v2fly/fhs-install-v2ray
TO MIGRATE: https://github.com/v2fly/fhs-install-v2ray/wiki/Migrate-from-the-old-script-to-this

打开网址https://github.com/v2fly/fhs-install-v2ray 找到最新安装脚本,运行:

bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)

安装完成,会看到提示,说明v2ray已经安装成功:

info: V2Ray v4.32.0 is installed.
You may need to execute a command to remove dependent software: yum remove curl unzip
Please execute the command: systemctl enable v2ray; systemctl start v2ray

设置v2ray开机自启动:

systemctl enable v2ray

其他命令:

systemctl start v2ray #开启v2ray
systemctl stop v2ray #停止v2ray

2、宝塔创建一个网站

如果服务器没安装nginx,先用宝塔面板安装nginx服务器软件。

解析一个二级域名(例如cs.xxx.com),添加网站,php版本选择纯静态,然后开启SSL。

修改配置文件,在#SSL-END后面添加代码:

    location /cs
    {
        proxy_pass http://127.0.0.1:你的端口号;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;
        proxy_read_timeout 300s;
    }

其中/cs为ws的path,端口号改为自己的端口,后面v2ray配置会用到,然后点击保存。

3、修改v2ray配置文件

进入/etc/v2ray/目录,有的是/usr/local/etc/v2ray/,编辑 config.json 文件 将里面全部代码改为:

{
  "policy": {
    "levels": {
      "0": {
        "uplinkOnly": 0,
        "downlinkOnly": 0,
        "connIdle": 150,
        "handshake": 4
      }
    }
  },
  "inbound": {
    "listen": "127.0.0.1",
    "port": 你的端口号,    //这里填写刚才网站配置的端口号,复制脚本请删除这句注释
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "e1bc89df-c245-4da6-90cc-2d20ad80a611",    //这里填写一个UUID,没有的话可以在线生成一个,复制脚本请删除这句注释
          "level": 1,
          "alterId": 32
        }
      ]
    },
    "streamSettings": {
      "network": "ws",
      "security": "auto",
      "wsSettings": {
        "path": "/cs",   //这里填写刚才网站配置里location的path,复制脚本请删除这句注释
        "headers": {
          "Host": "cs.xxx.com"  //这里填写刚才网站解析的域名,复制脚本请删除这句注释
        }
      }
    }
  },
  "outbound": {
    "protocol": "freedom",
    "settings": { }
  },
  "outboundDetour": [
    {
      "protocol": "blackhole",
      "settings": { },
      "tag": "blocked"
    }
  ],
  "routing": {
    "strategy": "rules",
    "settings": {
      "rules": [
        {
          "type": "field",
          "ip": [
            "0.0.0.0/8",
            "10.0.0.0/8",
            "100.64.0.0/10",
            "127.0.0.0/8",
            "169.254.0.0/16",
            "172.16.0.0/12",
            "192.0.0.0/24",
            "192.0.2.0/24",
            "192.168.0.0/16",
            "198.18.0.0/15",
            "198.51.100.0/24",
            "203.0.113.0/24",
            "::1/128",
            "fc00::/7",
            "fe80::/10"
          ],
          "outboundTag": "blocked"
        }
      ]
    }
  }
}

4、配置电脑或手机安装v2ray客户端

客户端下载地址参考:v2ray

客户端配置参考:v2ray客户端配置

其他参考:UUID生成工具



评论

提交取消回复
[face]@
[uname]  [add_time]
[content]
[reply]
加载更多评论