HAproxy source package installation
- System environment: Centos 7 x64 bit
- Service version: haproxy-1.7.8.tar.gz
- Compiler: gcc
Download the installation package locally and unzip it
Enter the decompression directory
Specify the build path
Compile and install
View haproxy version
Copy the haproxy startup service to the specified directory
Add a startup script to the system service directory and add startup permissions to the script
Create a system account
Create a config file directory
Create configuration file
global
log 127.0.0.1 local3 info
chroot /usr/local/haproxy
user haproxy
group haproxy
daemon
maxconn 4000
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
frontend http_front
bind *:80
stats uri /haproxy?stats
default_backend http_back
backend http_back
balance roundrobin
option httpchk GET /index.html
option forwardfor header X-Forwarded-For
server node1 192.168.1.166:80 check inter 2000 rise 3 fall 3 weight 30
server node2 192.168.1.110:80 check inter 2000 rise 3 fall 3 weight 30
Open the rsyslog file, configure.
Remove the # sign in front of the following two lines
$ModLoad imudp
$UDPServerRun 514
and add the following line
local3.* /var/log/haproxy.log
restart rsyslog
start haproxy