haproxy服务器1:192.168.79.150
haproxy服务器2:192.168.79.160
WEB1(http服务器):192.168.79.20
WEB2(http服务器):192.168.79.21
keepalived服务器:192.168.79.150
VIP 192.168.79.10
httpd WEB1,2服务器
yum -y install httpd
systemctl start httpd
cd /var/www/html
vim index.html
WEB1:a
WEB2:b
haproxy1服务器:
yum -y install haproxy
[root@localhost haproxy]# haproxy -v
HA-Proxy version 1.5.18 2016/05/10
Copyright 2000-2016 Willy Tarreau <willy@haproxy.org>
vim /etc/haproxy/haproxy.cfg
frontend main *:80
64 acl url_static path_beg -i /static /images /javascript /
stylesheets 65 acl url_static path_end -i .jpg .gif .png .css .js
66
67 # use_backend static if url_static
68 ! use_backend static
69 # default_backend app
74 backend static #通过backend关键字定义