轻松配置 V2Ray 新协议:VLESS

v2ray 的核心版本需要 4.27 以上才支持这个 VLESS 协议,配置前请查看版本。

全新安装

apt -y install curl
curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh
chmod +x install-release.sh
./install-release.sh

启动v2ray/设置开机自启

systemctl start v2ray
systemctl enable v2ray

安装 nginx/certbot

apt -y install nginx python-certbot-nginx

新建 nginx 站点配置文件

nano /etc/nginx/conf.d/v2raycert.conf
server {
      listen 80;
      server_name naive.imlala.best; # 换成你的域名用于使用 certbot 申请支持自动续期的 let's encrypt 证书
}

申请证书

certbot --nginx --agree-tos --no-eff-email --email xxxxx@qq.com

重新配置 nginx

nano /etc/nginx/conf.d/v2raycert.conf

注释掉 certbot 的自动配置 <加 # 即是注释了改行>

# listen 443 ssl; # managed by Certbot

重载 nginx

systemctl reload nginx

将申请的证书复制到如下目录,并更改所有者,生成一个uuid

cp /etc/letsencrypt/live/naive.imlala.best/fullchain.pem /usr/local/etc/v2ray
cp /etc/letsencrypt/live/naive.imlala.best/privkey.pem /usr/local/etc/v2ray
chown -R nobody:nogroup /usr/local/etc/v2ray/
v2ctl uuid

编辑v2ray的配置文件

nano /usr/local/etc/v2ray/config.json
{
  "log": {
    "loglevel": "info",
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log"
  },
  "inbounds": [
    {
      "port": 443,
      "protocol": "vless",
      "settings": {
         "clients": [
           {
             "id": "你刚才生成的UUID"
           }
         ],
         "decryption": "none",
         "fallback": {
           "port": 80
         }
      },
      "streamSettings": {
        "network":"tcp",
        "security": "tls",
        "tlsSettings": {
          "alpn": [
            "http/1.1"
          ],
          "certificates": [
            {
              "certificateFile": "/usr/local/etc/v2ray/fullchain.pem",
              "keyFile": "/usr/local/etc/v2ray/privkey.pem"
            }
          ]
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    }
  ]
}

测试配置

v2ray -config /usr/local/etc/v2ray/config.json -test

最后重启 v2ray 即可

systemctl restart v2ray

旧版本升级

停止 systemd 服务

systemctl disable v2ray
systemctl stop v2ray

删除 systemd 服务文件和旧版 v2ray

rm -rf /etc/systemd/system/v2ray.service
rm -rf /usr/bin/v2ray/

把原来的配置文件目录复制到新脚本需要的路径

mv /etc/v2ray/ /usr/local/etc/

更改日志文件的所有者

chown -R nobody:nogroup /var/log/v2ray

安装新版本

apt -y install curl
curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh
chmod +x install-release.sh
./install-release.sh

注意:如果是升级到最新版的,systemd 需要 reload 一下

systemctl daemon-reload

😁猜你喜欢

    发表回复

    电子邮件地址不会被公开。必填项已用 * 标注