安装 V2Ray
使用 Docker 安装
- 安装 Docker:
curl -fsSL https://get.docker.com | bash -s docker
- 拉取 V2Ray 镜像:
docker pull v2ray/v2ray:latest
- 启动 V2Ray 容器:
docker run -d --name v2ray -p 108:108 --restart always --volume /etc/v2ray:/etc/v2ray v2ray/v2ray:latest
使用 Docker Compose 安装
- 创建
docker-compose.yml文件:version: '3' services: v2ray: image: v2ray/v2ray:latest container_name: v2ray restart: always ports: - "108:108" volumes: - "/etc/v2ray:/etc/v2ray" environment: - V2RAY_STATIC=1 - V2RAY_MAX_UPSTREAM=1 - V2RAY_UPSTREAM=10.10.1.10运行 Docker Compose:
docker-compose up -d
配置 V2Ray 代理服务器
使用 Docker
- 进入 V2Ray 容器:
docker exec -it v2ray sh
- 运行配置命令:
./v2ray -config "config.json"
- 生成配置文件
config.json:{ "inbound": { "listen": "...:108", "Transparent": true, "forward": "127...1:1081", "DNS": "127...1" }, "outbound": { "listen": "127...1:1081", "forward": "10.10.1.10:80", "DNS": "127...1" } } - 重新应用配置:
./v2ray -reload
使用文件配置
- 创建
config.json文件:{ "inbound": { "listen": "...:108", "Transparent": true, "forward": "127...1:1081", "DNS": "127...1" }, "outbound": { "listen": "127...1:1081", "forward": "10.10.1.10:80", "DNS": "127...1" } } - 启动 V2Ray:
./v2ray -config "config.json"
配置客户端代理
浏览器
- 打开浏览器,设置为无痕模式。
- 进入设置,选择网络。
- 配置代理设置:
- 代理服务器地址:
...:108 - 代理服务器端口:
108 - 使用 HTTP 或 HTTPS(如果需要加密,生成 SSL 证书)
- 代理服务器地址:
应用程序
- 查看应用程序(如浏览器、Postman)的代理设置。
- 配置代理地址和端口:
- 代理地址:
...:108 - 代理端口:
108
- 代理地址:
生成 SSL 证书(可选)
为了加密流量,建议生成 SSL 证书:
- 安装
certbot:pip install certbot
- 生成证书:
certbot certonly --server --ip your_domain.com:80
- 将证书文件复制到 V2Ray 配置目录中。
配置防火墙
根据你的操作系统配置防火墙:
- Linux:
iptables -P INPUT ACCEPT iptables -A INPUT -p tcp --dport 108 -j ACCEPT iptables -A INPUT -p tcp --dport 808 -j ACCEPT service iptables save service iptables restart
- Windows: 使用 Windows 防火墙配置规则。
测试配置
- 从内网访问目标服务器,确保流量通过代理。
- 检查 V2Ray 日志:
docker logs -f v2ray
安全注意事项
- 定期更新 V2Ray 和相关软件。
- 确保代理服务器只允许授权访问。
- 配置访问控制列表(ACL)。
通过以上步骤,你可以配置一个基本的 V2Ray 代理服务器,根据你的需求,可能需要进一步定制配置文件和安全设置。









