HAProxy的是一个免费的,非常快速和可靠的解决方案,提供 高可用性, 负载均衡和代理对TCP和基于HTTP的应用程序。它特别适用于流量非常高的网站,并为世界上访问量最大的网站提供支持。多年来,它已成为事实上的标准开源负载均衡器,现在随大多数主流Linux发行版一起提供,并且通常默认部署在云平台中。(Google翻译)
HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It is particularly suited for very high traffic web sites and powers quite a number of the world’s most visited ones. Over the years it has become the de-facto standard opensource load balancer, is now shipped with most mainstream Linux distributions, and is often deployed by default in cloud platforms.
简单来说HAProxy功能强大,用于负载均衡、代理用的,端口转发功能的应用场景也是很广的。由于买了一台香港的VPS,然而刚刚好对我所在公司网络环境体验非常差,所我的就是用作中继节点加速网络的。
加速的结构:本地客户端–>具备HAProxy端口转发的VPS–>服务器端VPS–>这样就可以愉快4K看视频上网。。。。
1、安装
# Debian/Ubuntu系统:
apt-get -y install haproxy
# Centos系统:
yum -y install haproxy
2、添加配置
vi /etc/haproxy/haproxy.cfg
端口和服务器IP自己修改写入一下配置:
global
defaults
log global
mode tcp
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
frontend ss-in
bind *:本地端口或端口段 430 888-8888
default_backend ss-out
backend ss-out
server server1 服务器IP maxconn 4096
3、其它
服务启动
systemctl start haproxy
开机自启
systemctl enable haproxy
重启服务
systemctl restart haproxy
注意:转发端口号和被转发端口是一样的。