1、安裝和更新 V2Ray
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)
2、安裝和更新 geoip.dat 和 geosite.dat
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh)
3、编辑配置文件
vi /usr/local/etc/v2ray/config.json
{
"log":{
"loglevel":"warning",
"access":"/var/log/v2ray/access.log",
"error":"/var/log/v2ray/error.log"
},
"inbounds":[
{
"port":9999,
"protocol":"vmess",
"settings":{
"clients":[
{
"id":"e7358c59-ba27-4151-bcb3-a01ab7d96029",
"level":1,
"alterId":0
}
]
},
"streamSettings":{
"network":"ws",
"wsSettings":{
"path":"/pass"
}
},
"listen":"127.0.0.1"
}
],
"outbounds":[
{
"protocol":"freedom"
},
{
"protocol":"blackhole",
"settings":{
},
"tag":"blocked"
}
],
"routing":{
"rules":[
{
"type":"field",
"ip":[
"geoip:private"
],
"outboundTag":"blocked"
}
]
}
}
4、启动服务
systemctl enable v2ray && systemctl restart v2ray
5、Nginx设置
location /pass { # 与 V2Ray 配置中的 path 保持一致
proxy_redirect off;
proxy_pass http://127.0.0.1:9999; # v2ray监听地址
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
# Show real IP in v2ray access.log
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
6、Cf设置
1) 开启dns only
2) rules -> xxx/pass -> cache level -> ByPass
3) ssl/tls -> full
7、客户端
Windows v2rayN-Core 官网下载
Android v2rayNG 官网下载
iOS Shadowrocket AppStore
8、v2rayN设置(红色区域和Nginx设置保持一致;蓝色区域和v2ray服务器保持一致;紫色区域为固定wss协议和端口)
9、config
{
"log": {
"loglevel": "warning",
"access":"/var/log/v2ray/access.log",
"error":"/var/log/v2ray/error.log"
},
"inbounds": [
{
"port": 6688,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "e7358c59-ba27-4151-bcb3-a01ab7d96029",
"level": 1,
"alterId": 0
}
]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "/ads"
}
},
"listen": "0.0.0.0"
}
],
"outbounds": [
{
"protocol": "freedom"
},
{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}
],
"routing": {
"rules": [
{
"type": "field",
"ip": ["geoip:private"],
"outboundTag": "blocked"
}
]
}
}
10、docker
docker pull mowen99/goserver:latest &&
docker run -itd -p 127.0.0.1:6688:6688 --name v2ray --privileged -v /opt/v2ray:/etc/v2ray -v /opt/v2ray/log:/var/log/v2ray mowen99/goserver:latest
docker run -itd -p 2017:2017 -p 20170-20172:20170-20172 --restart=always --name v2raya --privileged -e V2RAYA_V2RAY_BIN=/usr/local/bin/v2ray -e V2RAYA_LOG_FILE=/var/log/v2raya.log -v /data/v2raya:/etc/v2raya -v /data/v2raya/log:/var/log/v2raya mowen99/go:1.20.3