1、安装haproxy

yum -y install haproxy

2、配置haproxy

[root@haproxy ~]# vim /etc/haproxy/haproxy.cfg
listen ocservproxy
        bind *:443
        mode tcp
        balance roundrobin
        server static 192.168.31.12:443 check

[root@haproxy ~]# mkdir /var/log/haproxy -p
[root@haproxy ~]#  chmod a+w /var/log/haproxy/
[root@haproxy ~]#  vim /etc/rsyslog.conf

# Provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514
local2.* /var/log/haproxy/haproxy.log

# Provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 514
local2.* /var/log/haproxy/haproxy.log

[root@haproxy ~]#  vim /etc/sysconfig/rsyslog

SYSLOGD_OPTIONS="-r -x -m 0 -c 2"



[root@haproxy ~]# systemctl restart rsyslog
[root@haproxy ~]# systemctl restart haproxy

注意:192.168.31.12:443 是ocserv的服务器地址。将域名解析到haproxy的地址上,进行测试。

文档更新时间: 2021-09-24 16:22   作者:xtyang