yum -y install wget zip unzip vim
curl -Ls https://raw.githubusercontent.com/v2fly … release.sh | bash
脚本会自动安装这些东西:
/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 域名数据文件
/etc/systemd/system/v2ray.service Systemd Service
/etc/init.d/v2ray SysV 启动脚本
cat /proc/sys/kernel/random/uuid
1cf3afc3-9342-4215-85ca-64fba7d6d8ba
vim /usr/local/etc/v2ray/config.json
{
"inbounds": [{
"port": 61000,
// 因为还要用 Nginx 反代,这里直接监听本地就行
"listen": "127.0.0.1",
"protocol": "vmess",
"settings": {
"clients": [
{
// 用户 UUID,自己随机弄一个
"id": "1cf3afc3-9342-4215-85ca-64fba7d6d8ba",
"level": 1,
"alterId": 64
}
]
},
"streamSettings": {
// 指定底层传输方式为 WebSocket
"network": "ws",
"wsSettings": {
// 在哪个路径上提供 WS 服务,可自定义
"path": "/video"
}
}
}],
"outbounds": [{
"protocol": "freedom",
"settings": {}
},{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}],
"routing": {
"rules": [
{
// 默认规则,禁止访问服务器内网
"type": "field",
"ip": ["geoip:private"],
"outboundTag": "blocked"
}
]
}
}
3. 运行 V2Ray
配置完了,运行一下:
systemctl start v2ray
如果你的服务器不用 Systemd:
service v2ray start
# 要么
/etc/init.d/v2ray start
# 或者手动运行
/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json
curl -i http://127.0.0.1:61000/video
注意 curl 访问的端口和路径要和上面 V2Ray 中配置的一致,出现 400 Bad Request 就对了。
配置 Nginx (安装lnmp)
开启ipv6
以 Nginx 为例,找个合适的 server {} 块添加以下内容(这重定向语法够蛋疼的):
listen 443 ssl;
server_name oracle.6465.xyz;
ssl_certificate /usr/local/nginx/ssl/oracle.64659886.xyz/oracle.64659886.xyz.cer;
ssl_certificate_key /usr/local/nginx/ssl/oracle.64659886.xyz/oracle.64659886.xyz.key;
ssl_session_timeout 5m;
location /video {
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
set $is_v2ray 0;
if ($http_upgrade = "websocket") {
set $is_v2ray 1;
}
if ($is_v2ray = 1) {
# 仅当请求为 WebSocket 时才反代到 V2Ray
proxy_pass http://127.0.0.1:61000;
}
if ($is_v2ray = 0) {
# 否则显示正常网页
rewrite ^/(.*)$ /mask-page last;
}
}
curl -i https://v2.6465.xyz/video (404无法访问)
wscat -c https://v2.6465.xyz/video (命令不存在)
config.json内容:
离线