**首先,你需要有一个DDos高防的VPS或着服务器,比如OVH…** 然后我们在高防的VPS上安装Haproxy软件 ``` yum -y install haproxy ``` 然后打开默认配置文件/etc/haproxy/haproxy.cfg,并粘贴 ``` global # 全局配置,一般无需修改 log 127.0.0.1 local0 pidfile /var/run/haproxy.pid maxconn 4000 user haproxy group haproxy daemon defaults # 默认配置,可根据实际情况进行修改 log global mode tcp option tcplog option dontlognull retries 3 timeout connect 5000ms timeout client 50000ms timeout server 50000ms frontend local_467 # 前端监听本地的 467 端口 bind *:467 default_backend backend_ip_43_129_255_54 backend backend_ip_43_129_255_54 # 后端配置,将请求转发到 IP 为 43.129.255.54 的 465 端口 mode tcp server server-1 43.129.255.54:465 check ``` 然后放行端口467 ``` iptables -I INPUT -p tcp --dport 467 -j ACCEPT iptables-save > /etc/sysconfig/iptables ``` 重启Haproxy并设置软件开机自启动。依次输入一下命令: ``` service haproxy restart chkconfig haproxy on ``` Loading... **首先,你需要有一个DDos高防的VPS或着服务器,比如OVH…** 然后我们在高防的VPS上安装Haproxy软件 ``` yum -y install haproxy ``` 然后打开默认配置文件/etc/haproxy/haproxy.cfg,并粘贴 ``` global # 全局配置,一般无需修改 log 127.0.0.1 local0 pidfile /var/run/haproxy.pid maxconn 4000 user haproxy group haproxy daemon defaults # 默认配置,可根据实际情况进行修改 log global mode tcp option tcplog option dontlognull retries 3 timeout connect 5000ms timeout client 50000ms timeout server 50000ms frontend local_467 # 前端监听本地的 467 端口 bind *:467 default_backend backend_ip_43_129_255_54 backend backend_ip_43_129_255_54 # 后端配置,将请求转发到 IP 为 43.129.255.54 的 465 端口 mode tcp server server-1 43.129.255.54:465 check ``` 然后放行端口467 ``` iptables -I INPUT -p tcp --dport 467 -j ACCEPT iptables-save > /etc/sysconfig/iptables ``` 重启Haproxy并设置软件开机自启动。依次输入一下命令: ``` service haproxy restart chkconfig haproxy on ``` Last modification:May 29, 2023 © Allow specification reprint Like 如果觉得我的文章对你有用,请随意赞赏