· 7 years ago · Dec 03, 2017, 08:00 AM
1Centos 6.4 64 Bit
2Webserver: Lighttpd
3All running in ESXI
4virtual IP: 192.168.1.6
5LB1: 192.168.1.4
6LB2: 192.168.1.5
7Webserver 1: 192.168.1.12
8Webserver 2: 192.168.1.13
9Gateway: 192.168.1.1
10
11global_defs {
12 notification_email {
13 myemail@gmail.com
14 }
15 notification_email_from keepalived@domain.local
16 smtp_server 192.168.1.4
17 smtp_connect_timeout 30
18 router_id 192.168.1.1
19}
20
21vrrp_script chk_haproxy {
22script "killall -0 haproxy"
23interval 1 # check every second
24weight 2 # add 2 points of prio if OK
25}
26
27vrrp_instance VI_1 {
28 state MASTER
29 interface eth0
30 virtual_router_id 51
31 priority 101 #priority 101 for master
32 advert_int 1
33 authentication {
34 auth_type PASS
35 auth_pass 1111
36 }
37 virtual_ipaddress {
38 192.168.1.6
39
40 }
41
42 track_script {
43 chk_haproxy
44 }
45
46 }
47
48#---------------------------------------------------------------------
49# Example configuration for a possible web application. See the
50# full configuration options online.
51#
52# http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
53#
54#---------------------------------------------------------------------
55
56#---------------------------------------------------------------------
57# Global settings
58#---------------------------------------------------------------------
59global
60 # to have these messages end up in /var/log/haproxy.log you will
61 # need to:
62 #
63 # 1) configure syslog to accept network log events. This is done
64 # by adding the '-r' option to the SYSLOGD_OPTIONS in
65 # /etc/sysconfig/syslog
66 #
67 # 2) configure local2 events to go to the /var/log/haproxy.log
68 # file. A line like the following can be added to
69 # /etc/sysconfig/syslog
70 #
71 # local2.* /var/log/haproxy.log
72 #
73 log 127.0.0.1 local2
74
75 chroot /var/lib/haproxy
76 pidfile /var/run/haproxy.pid
77 maxconn 4000
78 user haproxy
79 group haproxy
80 daemon
81
82 # turn on stats unix socket
83 stats socket /var/lib/haproxy/stats
84
85#---------------------------------------------------------------------
86# common defaults that all the 'listen' and 'backend' sections will
87# use if not designated in their block
88#---------------------------------------------------------------------
89defaults
90 mode http
91 log global
92 option httplog
93 option dontlognull
94 option http-server-close
95 option forwardfor except 127.0.0.0/8
96 option redispatch
97 retries 3
98 timeout http-request 10s
99 timeout queue 1m
100 timeout connect 10s
101 timeout client 1m
102 timeout server 1m
103 timeout http-keep-alive 10s
104 timeout check 10s
105 maxconn 3000
106
107#---------------------------------------------------------------------
108# main frontend which proxys to the backends
109#---------------------------------------------------------------------
110frontend main *:80
111# acl url_static path_beg -i /static /images /javascript /stylesheets
112# acl url_static path_end -i .jpg .gif .png .css .js
113
114# use_backend static if url_static
115# default_backend view
116
117#---------------------------------------------------------------------
118# static backend for serving up images, stylesheets and such
119#---------------------------------------------------------------------
120#backend static
121# balance roundrobin
122# server static 127.0.0.1:4331 check
123
124#---------------------------------------------------------------------
125# round robin balancing between the various backends
126#---------------------------------------------------------------------
127backend app
128mode tcp
129 balance roundrobin
130 server server1 192.168.1.12:80 check inter 2000 rise 2 fall 5
131 server server2 192.168.1.13:80 check inter 2000 rise 2 fall 5
132
133503 Service Unavailable No server is available to handle this request.
134
135global
136 log 127.0.0.1 local2
137
138 chroot /var/lib/haproxy
139 pidfile /var/run/haproxy.pid
140 maxconn 4000
141 user haproxy
142 group haproxy
143 daemon
144
145 stats socket /var/lib/haproxy/stats
146
147defaults
148 mode http
149 log global
150 option httplog
151 option dontlognull
152 option http-server-close
153 option forwardfor except 127.0.0.0/8
154 option redispatch
155 retries 3
156 timeout http-request 10s
157 timeout queue 1m
158 timeout connect 10s
159 timeout client 1m
160 timeout server 1m
161 timeout http-keep-alive 10s
162 timeout check 10s
163 maxconn 3000
164
165frontend main *:80
166
167backend app
168 mode tcp
169 balance roundrobin
170 server server1 192.168.1.12:80 check inter 2000 rise 2 fall 5
171 server server2 192.168.1.13:80 check inter 2000 rise 2 fall 5