v2ray安装
CDN那里把域名指向VPS后,把小云朵点灰,即只提供DNS
apt-get update
apt-get install curl -y
bash <(curl -s -L https://git.io/v2ray.sh)
如果要安装和网站同时用,加密模式选WebSocket + TLS
自动配置tls选否 端口选
如果不安装网站加密方式选VLESS_WebSocket_TLS
然后开启分流
查看V2Ray 和 Caddy 是否运行v2ray status
生成 vmess URL 链接v2ray url
生成二维码链接v2ray qr
设置好后再把CDN代理打开,云朵点亮
使ping没反应,忽略icmp包,输入:echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
恢复使用ping命令,输入:echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all
#关于一些名词说明
传输协议ws:就是启用了路由路径,方便反向代理来实现分流,如果没有指定路由路径则直接为tcp
自己安装原版v2ray
上传到/etc/v2ray/
并将v2ray和v2ctl设置权限允许运行
#创建下面两个日志文件,设置允许写,日志可以不设置
"/var/log/v2ray/access.log"
"/var/log/v2ray/error.log"
编辑/etc/v2ray/config.json:
{
"inbounds": [
{
"port": 4921,//端口
"listen":"127.0.0.1",//只监听本机,删除它可外网IP直连
"protocol": "vmess",//协议
"settings": {
"clients": [
{
"id": "b831381d-6324-4d53-ad4f-8cda48b30811",//对应客户端的用户ID
"alterId": 0
}
],
"decryption": "none"//加密方式没有
},
"streamSettings": {
"network": "ws",//网络方法
"wsSettings": {
"path": "/fachun"//路由
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}
#如果要作为系统服务启动创建/etc/systemd/system/v2ray.service文件:
[Unit]
Description=V2Ray Service
Documentation=https://www.v2fly.org/
After=network.target nss-lookup.target
[Service]
User=root
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ExecStart=/etc/v2ray/v2ray -config /etc/v2ray/config.json
Restart=on-failure
RestartPreventExitStatus=23
[Install]
WantedBy=multi-user.target
#重新加载systemd配置systemctl daemon-reload
编辑caddy配置文件:
fachun.3kj.online {
tls /home/ssl/3kj.online.pem /home/ssl/3kj.online.key
reverse_proxy https://www.bmw.com {
header_up Host {upstream_hostport}
header_up X-Forwarded-Host {host}
}
@v2ray {
path /fachun
header Connection Upgrade
header Upgrade websocket
}
reverse_proxy @v2ray localhost:4921
}
#启动v2raysystemctl start v2ray
#重启v2raysystemctl restart v2ray
#让v2ray开机自启动sudo systemctl enable v2ray
#验证服务是否运行systemctl status v2ray
#停止v2raysystemctl stop v2ray
单次运行
cd /etc/v2ray
#打开v2ray目录./v2ray --config=/etc/v2ray/config.json
#运行配置文件