本教程适用于alpine系统。其他系统请忽略,

准备说明。
如果发现不能右键粘贴,怎么办?试试这个的方法
粘贴进去缩进异常?粘贴前设置下 set paste 再尝试粘贴
1- 安装v2

apk add v2ray 

2- 创建配置v2配置文件

vim /etc/v2ray/config.json

清空文件。键入下面的内容,链接端口为8321 .ID fa806487-2d26-4236-98b6-as85cc852197,协议ws,路径/dl

{
  "inbounds": [
    {
      "port": 8321,
      "listen":"127.0.0.1",
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "fa806487-2d26-4236-98b6-as85cc852197",
            "alterId": 0
          }
        ]
      },
      "streamSettings": {
        "network": "ws",
        "wsSettings": {
        "path": "/dl"
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    }
  ]
}

3- 配置v2启动文件,由于默认安装的启动文件无法启动。这里我改了下可以启动的

vim /etc/init.d/v2ray

清空文件内容后输入下面的内容。

#!/sbin/openrc-run
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

name="V2ray"
description="The best v2ray, with XTLS support"
description_checkconfig="Test configuration file"
V2_CONFIG="/etc/v2ray/config.json"
V2_PIDFILE="/run/v2ray.pid"
V2_LOG="/var/log/v2ray.log"

checkconfig() {
    if [ ! -f ${V2_CONFIG} ]; then
        ewarn "${V2_CONFIG} does not exist."
    fi
}

command="/usr/bin/v2ray"
command_args="run -c /etc/v2ray/config.json"
command_user="nobody"

pidfile="/run/v2ray.pid"
command_background="yes"

extra_commands="checkconfig"

depend() {
    need net
}


start_pre() {
    checkconfig
}

下面配置下nginx链接到v2

1- 没有安装nginx 的运行下安装命令

apk add nginx

2- 配置

vim /etc/nginx/http.d/default.conf

清空内容输入下面的内容,证书自己准备。

server {
        listen [::]:80;
        listen [::]:443 ssl;
    
    server_name u.360063.xyz;
    ssl_certificate /home/ssl/ssl.crt;
    ssl_certificate_key /home/ssl/ssl.key;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    
    root /home/www;
    index index.html;
    location /dl {

    proxy_redirect off;
    proxy_pass http://127.0.0.1:8321;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    
    
    }


}

启动相关服务

1- 添加自启动

rc-update v2ray default
rc-update nginx default

2- 启动服务

rc-service v2ray start
rc-service nginx start

完成。开始使用吧