利用Nginx/Haproxy实现V2ray+ws+Tls多落地VPS负载均衡
1:准备工具:国外VPS选购三台分别用三个域名进行解析好其IP地址;准备国内NAT或VDS中转机一台;
2:在国外VPS上分别安装V2ray+ws+tls节点:
这里直接用wulabing onekey安装:
1 | wget -N --no-check-certificate -q -O install.sh "https://raw.githubusercontent.com/wulabing/V2Ray_ws-tls_bash_onekey/master/install.sh" && chmod +x install.sh && bash install.sh |
3:安装完成获取配置后对三台国外VPS进行配置修改;原则为UUID、alterID、路径参数皆需一致
配置修改时要注意须停止Nginx和V2ray服务
3.1修改Nginx配置:vi /etc/nginx/conf/conf.d/v2ray.conf
将里面的location路径修改成一致
3.2修改V2ray配置
vi /etc/v2ray/config.json
修改里面的path
以上修改完成后须重新启动V2ray和Nginx
相关启动命令如下:
1 | systemctl start v2ray |
相关停止命令
1 | systemctl stop nginx |
2:在国内NAT/VDS上安装nginx 这里用centos7系统:
1 | yum -y install nginx |
3:写入如下配置文件:
1 | stream { |
4:开启Nginx同时检查Nginx运行状态
1 | systemctl start nginx & systemctl status nginx |
5:关闭防火墙
1 | systemctl stop firewalld |
6:关闭SELinux
1 | sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config |
7:配置客户端即可使用
IP轮询效果查看
拓展:Haproxy负载均衡:
yum -y install haproxy
vi /etc/haproxy/haproxy.cfg
配置文件如下:
1 | global |
service haproxy start
systemctl status haproxy.service
systemctl start haproxy
systemctl enable haproxy