搭建v2ray+ws+tls+cdn教程

V2ray是一个代理工具,可以帮助用户更快、更安全地访问网络。本教程会介绍如何将V2ray与WebSocket、TLS、CDN结合搭建,以获得更好的、更安全的网络体验。

1.安装unzip

1
apt install unzip

新建文件夹/root/v2,并移动过去。后面所有操作都在这里进行。

1
2
mkdir -p /root/v2
cd /root/v2

2.下载caddy和v2ray。默认下载的是Linux amd64位版本。
Caddy官网:https://caddyserver.com/download
V2ray Github仓库:https://github.com/v2fly/v2ray-core

1
2
3
wget -O caddy --no-check-certificate "https://onedrive.baxx.eu.org/api/raw/?path=/caddy_linux_amd64" 
wget --no-check-certificate "https://github.com/v2fly/v2ray-core/releases/download/v4.45.2/v2ray-linux-64.zip" && unzip -o v2ray-linux-64.zip v2ray v2ctl geosite.dat geoip.dat && rm v2ray-linux-64.zip
chmod +x caddy v2ray v2ctl

3.新建文件:Caddyfile

1
2
3
4
5
http://example.com {
reverse_proxy /hello 127.0.0.1:10000 {
header_up -Origin
}
}

Cloudflare的加密模式要选择Flexible

4.新建文件:config.json。这是v2ray的配置文件。
VMESS:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{
"log": {
"loglevel": "info"
},
"inbounds": [
{
"protocol": "vmess",
"port": 10000,
"listen": "127.0.0.1",
"settings": {
"clients": [
{
"alterId": 0,
"id": "d80d1881-a00f-7153-1740-0ccff5b916ca"
}
]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "/hello"
}
}
}
],
"outbounds": [
{
"tag": "direct",
"protocol": "freedom"
}
]
}

VLESS:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{
"inbounds": [
{
"port": 10000,
"listen":"127.0.0.1",
"protocol": "vless",
"settings": {
"decryption": "none",
"clients": [
{
"id": "d80d1881-a00f-7153-1740-0ccff5b916ca",
"level": 0
}
]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "/hello"
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}

d80d1881-a00f-7153-1740-0ccff5b916ca为UUID
/hello为路径
如果没有UUID,执行./v2ctl uuid,会随机输出一个。

5.后台运行
Caddy:

1
./caddy start

V2ray:

1
2
3
screen -S v2ray
./v2ray
Ctrl A+D 退出

如果没有screen要先安装:

1
apt install screen

当前目录除了以下文件,其他都可以删除。

1
v2ray v2ctl geosite.dat geoip.dat caddy Caddyfile config.json

6.客户端下载
v2rayN:https://github.com/2dust/v2rayN/releases
v2rayNG:https://github.com/2dust/v2rayNG/releases