v2ray基于caddy的VMESS+WS+TLS+Website+CDN豪华配置

0. 预备

https://github.com/dylanbai8/V2Ray_ws-tls_Website_onekey.git

  1. 购买域名、VPS;
  2. 注册cloudflare,提前24小时配置NS并解析域名。
  3. 确保所解析的域名Status位置关闭默认的cdn加速,变为灰色云朵状态。

PS:在接下来步骤之前,勿必保持所解析的域名Status处为灰色云朵(及关闭cdn)。重做系统或重新安装时也勿必关闭此处设置。

1. 安装v2ray

https://github.com/Jrohy/multi-v2ray.git

  1. source <(curl -sL https://git.io/fNgqx) –zh
  2. 进入/etc/v2ray目录,将下面内容粘贴进入config文件,保存退出
  3. 命令行,v2ray,选择1,重启v2ray更新配置
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{
"log": {
"error": "/var/log/v2ray/error.log",
"access": "/var/log/v2ray/access.log",
"loglevel": "info"
},
"routing": {
"rules": [
{
"ip": [
"0.0.0.0/8",
"10.0.0.0/8",
"100.64.0.0/10",
"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",
"type": "field"
}
]
},
"inbounds": [
{
"protocol": "vmess",
"settings": {
"clients": [
{
"alterId": 16,
"id": "968d32da-872f-11e9-9757-23989767d2fc"
}
]
},
"streamSettings": {
"tlsSettings": {},
"security": "none",
"wsSettings": {
"connectionReuse": true,
"headers": {
"Host": "ss.example.com"#改为自己的域名
},
"path": "/v2ray/"
},
"httpSettings": {},
"network": "ws",
"quicSettings": {},
"tcpSettings": {},
"kcpSettings": {}
},
"port": 48065,
"listen":"127.0.0.1"
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
},
{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}
]
}

2. 安装caddy

https://github.com/sayem314/Caddy-Web-Server-Installer.git

  1. wget https://git.io/vra5C -O - -o /dev/null|sudo bash
  2. caddy install
  3. caddy service
  4. 修改/etc/Caddyfile 内容如下
  5. caddy restart
1
2
3
4
5
6
7
8
9
10
11
12
ss.example.com {  #改为自己域名
root /var/caddywww
gzip
tls example@126.com #改为自己的邮箱
log /var/log/caddy/access.log
errors /var/log/caddy/error.log
fastcgi / 127.0.0.1:9000 php
proxy /v2ray/ localhost:48065 {
websocket
header_upstream -Origin
}
}

3. 开启CDN

确认可以用客户端登录以后,进行一下操作

  1. 开启全程ssl加密
    在 Cloudflare 的 Crypto 那里设置 SSL 为 Full
  2. 开启cdn隐藏ip地址
    返回 Status 点击灰色云朵图标 将其变成 橙色云朵状态 开启cdn,即是 DNS and HTTP proxy(CDN)
Limin Wang wechat
Welcome!
I'm happy it's useful to you!
Show comments from Gitment