V2ray+Ws+Tls+Nginx 手动安装教程

通过 V2ray+Ws+Tls+Nginx 配置代理服务器,这种协议可以有效的避免服务器IP被墙,推荐使用。本教程以宝塔做实例。

安装宝塔

首先安装下边的宝塔面板7.2.0,安装面板完成后到里面安装Nginx服务。

# Centos安装命令:
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh
# Debian/Ubuntu 安装命令:
wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && bash install.sh

创建网站

在宝塔面板里面创建一个网站,并开启SSL(把强制开启HTTPS开启)。然后网站的配置文件中加入以下内容:
配置文件

location /v2ray
    {
        proxy_pass http://127.0.0.1:26509;
        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;
    }

安装V2ray:

V2Ray 手动搭建命令,一条一条复制粘贴到ssh命令行里,执行回车即可搭建完成。

# 下载v2ray服务端
wget https://yangwenqing.com/install_v2ray.tar.gz
# 解压v2ray服务端
tar -zxvf install_v2ray.tar.gz
# 创建/etc/v2ray/路径文件夹
mkdir /etc/v2ray
# 创建/usr/bin/v2ray路径文件夹
mkdir /usr/bin/v2ray
# 移动文件到/etc/v2ray
mv config.json /etc/v2ray
# 移动文件到/usr/bin/v2ray
mv geoip.dat geosite.dat v2ctl v2ray /usr/bin/v2ray
# 设置权限777
chmod 777 /etc/v2ray/*
# 设置权限777
chmod 777 /etc/v2ray/
# 设置权限777
chmod 777 /usr/bin/v2ray/*
# 设置权限777
chmod 777 /usr/bin/v2ray/
# 移动文件到/etc/systemd/system/
mv v2ray.service /etc/systemd/system/
# 设置权限777
chmod 777 /etc/systemd/system/v2ray.service
# 设置开机自启
systemctl enable v2ray.service
# 开始v2ray服务
systemctl start v2ray.service

V2ray配置:

安装完成V2ray后,需要修改一下配置文件,将/etc/v2ray/config.json里面内容全部删除,换成下边的配置文件

{
  "policy": {
    "levels": {
      "0": {
        "uplinkOnly": 0,
        "downlinkOnly": 0,
        "connIdle": 150,
        "handshake": 4
      }
    }
  },
  "inbound": {
    "listen": "127.0.0.1",
    "port": 26509,
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "8f682c0e-0d80-4ac8-9ba8-d23b2705b58a",
          "level": 1,
          "alterId": 32
        }
      ]
    },
    "streamSettings": {
      "network": "ws",
      "security": "auto",
      "wsSettings": {
        "path": "/v2ray",
        "headers": {
          "Host": "korea.yovter.xyz"
        }
      }
    }
  },
  "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"
        }
      ]
    }
  }
}

注意:V2ray 端口为26509,自行放行防火墙,上边的"Host": "korea.yovter.xyz"需要改成你在宝塔时创建的网站地址。其他ID path可按自己需求更改(改了的话记得宝塔配置文件也样一一对应)。

Last modification:January 12th, 2023 at 05:05 pm
If you think my article is useful to you, please feel free to appreciate