安全传输
当要和服务器安全传输时,可以使用v2fly。
js 生成UUID
js
crypto.randomUUID();
服务端安装
bash
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)
启动
shell
启动 V2Ray:
# systemctl start v2ray
停止 V2Ray
# systemctl stop v2ray
查看服务状态
# service v2ray status
设置开机自启动 V2Ray:
# systemctl enable v2ray
配置
- 修改配置文件:
shell
vim /usr/local/etc/v2ray/config.json
- vmess 配置如下
json
{
"inbounds": [
{
"port": 9901,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "使用生成的UUID",
"alterId": 0,
"security": "auto",
"level": 0
}
]
}
},
],
"outbounds": [
{
"protocol": "freedom"
}
]
}
配置文档 : https://www.v2fly.org/config/protocols/vless.html#outboundconfigurationobject
- 开放端口, 阿里云还需要开启安全组的端口,并重启服务器
shell
# centos系统 开了防火墙才使用
firewall-cmd --zone=public --add-port=9900-9999/tcp --permanent
firewall-cmd --zone=public --add-port=9900-9999/udp --permanent
# 刷新规则
firewall-cmd --reload
- 启动成功的样子
bash
# systemctl status v2ray
● v2ray.service - V2Ray Service
Loaded: loaded (/etc/systemd/system/v2ray.service; disabled; vendor preset: enabled)
Active: active (running) since Sun 2020-08-16 23:17:13 CST; 41min ago
Main PID: 1984 (v2ray)
Tasks: 6 (limit: 2359)
Memory: 6.9M
CGroup: /system.slice/v2ray.service
└─1984 /usr/local/bin/v2ray -confdir /usr/local/etc/v2ray/
客户端下载
客户端配置
json
{
"inbounds": [
{
"port": 1080, // SOCKS 代理端口,在浏览器中需配置代理并指向这个端口
"listen": "127.0.0.1",
"protocol": "socks",
"settings": {
"udp": true
}
}
],
"outbounds": [
{
"protocol": "vmess",
"settings": {
"vnext": [
{
"address": "server", // 服务器地址,请修改为你自己的服务器 ip 或域名
"port": 9901, // 服务器端口
"users": [
{
"id": "使用生成的UUID"
}
]
}
]
}
},
{
"protocol": "freedom",
"tag": "direct"
}
],
"routing": {
"domainStrategy": "IPOnDemand",
"rules": [
{
"type": "field",
"ip": [
"geoip:private"
],
"outboundTag": "direct"
}
]
}
}