在Windows系统上搭建V2Ray服务端详细教程
之前已经写了一篇如何在Windows搭建V2Ray服务端,这次更新一下。
一、准备工作
- 系统要求 - Windows 7 及以上版本(推荐 Windows 10/11 或 Windows Server 2016+)。
- 管理员权限(用于运行服务端和配置防火墙)。
 
- 下载 V2Ray - 访问官方 GitHub 发布页:https://github.com/v2fly/v2ray-core/releases
- 下载适用于 Windows 的压缩包(如 v2ray-windows-64.zip)。
 
二、安装与配置
1. 解压文件
- 将下载的压缩包解压到任意目录(例如 - C:\v2ray),目录结构应包含:- v2ray.exe # 主程序 v2ctl.exe # 辅助工具 config.json # 配置文件(需编辑) geosite.dat # 地理数据文件 geoip.dat # IP 数据文件
2. 编辑配置文件
- 用文本编辑器(如 Notepad++)打开 - config.json,参考以下配置模板(VMess 协议):- { "inbounds": [{ "port": 10086, // 监听端口(需开放防火墙) "protocol": "vmess", // 协议类型 "settings": { "clients": [{ "id": "b831381d-6324-4d53-ad4f-8cda48b30811", // 用户ID(可自行生成) "alterId": 64 // 额外ID }] } }], "outbounds": [{ "protocol": "freedom", // 直连模式 "settings": {} }] }- 关键参数说明: - port: 服务端监听端口(需在防火墙放行)。
- id: 客户端连接所需的 UUID(可用在线工具生成:UUID Generator)。
- alterId: 建议设置为- 64或更高(增强安全性)。
 
 
3. 放行防火墙端口
- 以管理员身份打开 PowerShell 或 CMD,运行以下命令: - New-NetFirewallRule -DisplayName "V2Ray" -Direction Inbound -Protocol TCP -LocalPort 10086 -Action Allow- 如果使用第三方防火墙,需手动添加规则允许指定端口的入站连接。
 
三、运行 V2Ray
1. 手动启动
- 打开 CMD,进入 V2Ray 目录并运行: - cd C:\v2ray v2ray.exe run -c config.json- 如果看到 V2Ray started提示,说明服务端已正常运行。
 
- 如果看到 
2. 设置为系统服务(可选)
- 使用 NSSM 工具将 V2Ray 注册为系统服务(后台运行): - 下载 NSSM:https://nssm.cc/download
- 安装服务: - nssm install v2ray- 在弹出窗口中设置: - Path: C:\v2ray\v2ray.exe
- Arguments: run -c C:\v2ray\config.json
- Startup directory: C:\v2ray
 
- Path: 
- 启动服务: - nssm start v2ray
 
四、客户端连接
- 客户端配置 
- 测试连接 - 确保客户端能正常连接,并通过 IP 检测网站 验证流量是否通过服务端。
 
五、优化与安全
- 启用 TLS(可选) - 配合域名和 SSL 证书(如 Let's Encrypt)配置 WebSocket + TLS,提升隐蔽性。
- 参考配置片段: - "inbounds": [{ "port": 443, "protocol": "vmess", "settings": { /* ... */ }, "streamSettings": { "network": "ws", "security": "tls", "tlsSettings": { "certificates": [{ "certificateFile": "C:\\ssl\\fullchain.cer", "keyFile": "C:\\ssl\\private.key" }] } } }]
 
- 动态端口(可选) - 在 inbounds中配置detour和portAllocation实现端口动态切换。
 
- 在 
常见问题
- 无法连接:检查防火墙、端口是否开放,以及服务端日志(error.log)。
- 速度慢:尝试更换端口或启用 mKCP 协议(牺牲稳定性换取速度)。
- 更新 V2Ray:替换 v2ray.exe和.dat文件后重启服务。
通过以上步骤,你已成功在 Windows 上搭建 V2Ray 服务端。如需更高级配置,可参考官方文档:V2Fly 官网。