V2ray搭建Nginx+TLS+Webocket代理方案

这应该是目前理论最隐蔽的代理方式,走的是真正意义上的https流量,是实际的网站流量,当然前提是你有一个网站,不过没有也没关系,只不过比较假而已 ::(滑稽)

V2ray服务端配置

配置文件位于/etc/v2ray/config.json,示例配置如下

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
{
"inbounds": [
{
"port": 10086, //监听端口
"listen":"127.0.0.1",
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "792c270e-2712-4efe-aa2f-a0578b120a78", //此处的为uuid,请不要使用这里的,请搜索uuid生成工具
"alterId": 64
}
]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "/v2ray" //此为分流路径,可自定义
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}

Nginx反向代理配置

示例配置

1
2
3
4
5
6
7
8
location /v2ray { //此处分流路径需与V2ray配置的路径一致
proxy_redirect off;
proxy_pass http://127.0.0.1:10086; //10086为监听的端口
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
}

当然这部分需要加到配置https的部分
需要注意的是,你的需要确保网站不会拦截到https://yourdomain/v2ray的请求,因为某些网站模板会直接返回一个自定义的404页面,导致无法使用代理,我踩过的坑不希望别人再踩

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
{
"inbounds": [
{
"port": 1080, //设置了一个监听在1080端口的代理
"listen": "127.0.0.1",
"protocol": "socks",
"domainOverride": ["tls","http"],
"settings": {
"auth": "noauth",
"udp": true
}
}
],
"outbounds": [
{
"protocol": "vmess",
"settings": {
"vnext": [
{
"address": "yourdomain", //此处为你的域名
"port": 443,
"users": [
{
"id": "792c270e-2712-4efe-aa2f-a0578b120a78", //uuid需与服务端一致
"alterId": 64
}
]
}
]
},
"streamSettings": {
"network": "ws",
"security": "tls",
"wsSettings": {
"path": "/v2ray" //同样分流路径也要一致
}
}
}
]
}

使用V2ray集成的shadowsocks

由于V2ray的安卓客户端极其难用,bug也多,所以在手机上还是使用shadowsocks,但是shadowsocks的配置就比较简单了
示例配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
"inbounds": [
{
"port": 12315, //监听端口
"protocol": "shadowsocks",
"settings": {
"method": "aes-256-gcm", //加密方式
"ota": true,
"password": "password" //密码
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}

把两种方案结合一下,最后就是这样的配置了

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
{
"inbounds": [
{
"port": 10086,
"listen":"127.0.0.1",
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "792c270e-2712-4efe-aa2f-a0578b120a78",
"alterId": 64
}
]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "/v2ray"
}
}
},
{
"port": 12315,
"protocol": "shadowsocks",
"settings": {
"method": "aes-256-gcm",
"ota": true,
"password": "password"
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}

参考:https://toutyrater.github.io/

V2ray搭建Nginx+TLS+Webocket代理方案

https://jktu.cc/V2ray搭建Nginx+TLS+Webocket代理方案/

作者

udp_bbr

发布于

2019-01-24

更新于

2020-03-25

许可协议