安装
一键安装: bash <(curl -L -s https://install.direct/go.sh)
- /usr/bin/v2ray/v2ray:V2Ray 程序;
- /usr/bin/v2ray/v2ctl:V2Ray 工具;
- /etc/v2ray/config.json:配置文件;
- /usr/bin/v2ray/geoip.dat:IP 数据文件
- /usr/bin/v2ray/geosite.dat:域名数据文件
快速入门
- 注意 json 里面去掉注释(v2ray 其实已经支持写注释了)
服务端
1
2
3
4
5
6
7
8
9
10
11
12
13{
"inbounds": [{
"port": 10086, // 服务器监听端口,必须和上面的一样
"protocol": "vmess",
"settings": {
"clients": [{ "id": "b831381d-6324-4d53-ad4f-8cda48b30811" }]
}
}],
"outbounds": [{
"protocol": "freedom",
"settings": {}
}]
}
客户端
1 | { |
pac完整版
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126// 20191204105605
// http://127.0.0.1:8070/config.json
{
"dns": {
"servers": [
"8.8.8.8"
]
},
"inbounds": [
{
"listen": "127.0.0.1",
"port": 1080,
"protocol": "socks",
"tag": "socksinbound",
"settings": {
"auth": "noauth",
"udp": false,
"ip": "127.0.0.1"
}
},
{
"listen": "127.0.0.1",
"port": 8001,
"protocol": "http",
"tag": "httpinbound",
"settings": {
"timeout": 0
}
}
],
"outbounds": [
{
"sendThrough": "0.0.0.0",
"mux": {
"enabled": false,
"concurrency": 8
},
"protocol": "vmess",
"settings": {
"vnext": [
{
"address": "120.27.3.135",
"users": [
{
"id": "b831381d-6324-4d53-ad4f-8cda48b30811",
"alterId": 0,
"security": "auto",
"level": 0
}
],
"port": 10086
}
]
},
"tag": "test",
"streamSettings": {
"wsSettings": {
"path": "",
"headers": {
}
},
"quicSettings": {
"key": "",
"security": "none",
"header": {
"type": "none"
}
},
"tlsSettings": {
"allowInsecure": false,
"alpn": [
"http/1.1"
],
"serverName": "server.cc",
"allowInsecureCiphers": false
},
"sockopt": {
},
"httpSettings": {
"path": "",
"host": [
""
]
},
"tcpSettings": {
"header": {
"type": "none"
}
},
"kcpSettings": {
"header": {
"type": "none"
},
"mtu": 1350,
"congestion": false,
"tti": 20,
"uplinkCapacity": 5,
"writeBufferSize": 1,
"readBufferSize": 1,
"downlinkCapacity": 20
},
"security": "none",
"network": "tcp"
}
}
],
"routing": {
"name": "all_to_main",
"domainStrategy": "AsIs",
"rules": [
{
"type": "field",
"outboundTag": "test",
"port": "0-65535"
}
]
},
"log": {
"error": "/var/folders/rj/892wklf97db2hbzj9c74ydfc0000gn/T/cenmrev.v2rayx.log/error.log",
"loglevel": "none",
"access": "/var/folders/rj/892wklf97db2hbzj9c74ydfc0000gn/T/cenmrev.v2rayx.log/access.log"
}
}
WebSocket+TLS+Web
TLS 的配置将写入 Nginx / Caddy / Apache 配置中,由这些软件来监听 443 端口(443 比较常用,并非 443 不可)
然后将流量转发到 V2Ray 的 WebSocket 所监听的内网端口(本例是 10086),V2Ray 服务器端不需要配置 TLS。
服务端v2ray 配置
1 | { |
Nginx配置
1 | server { |
Caddy 配置
Caddy 会自动申请证书并自动更新,所以使用 Caddy 不用指定证书、密钥1
2
3
4
5
6
7
8domain.com
{
log ./caddy.log
proxy /ray localhost:10086 {
websocket
header_upstream -Origin
}
}
Apache 配置
1 | <VirtualHost *:443> |
v2ray客户端配置
1 | { |
dd
反向代理
A: 家里内网环境
B:拥有公网IP的环境
C: 公司网络环境
A 会主动向 B 发起请求,建立起一个连接;
用户在 C 上向 B 发起请求,欲访问 A 上的私有网盘;
B 接受 C 的请求,通过 A 向 B 建立的连接转发给 A(即 B 反向连接了 A);
A配置
1 | { |
B公网环境
1 | { |
C其他环境
C正常配置连接B服务器配置即可。此时C的ip就是内网A的ip。
反向代理2
- 上面是局限于单端口,现在不限端口,和上面差不多,这时c连b
A 配置(内网环境)
1 | { |
B配置(公网服务器)
1 | { |
C配置(用户端环境)
C连B 11872 配置即可