-
Notifications
You must be signed in to change notification settings - Fork 106
/
haproxy-setup.sh
49 lines (41 loc) · 1020 Bytes
/
haproxy-setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
if [ ! -f /etc/haproxy/haproxy.cfg ]; then
# Install haproxy
/usr/bin/apt-get -y install haproxy
# Configure haproxy
cat > /etc/default/haproxy <<EOD
# Set ENABLED to 1 if you want the init script to start haproxy.
ENABLED=1
# Add extra flags here.
#EXTRAOPTS="-de -m 16"
EOD
cat > /etc/haproxy/haproxy.cfg <<EOD
global
daemon
maxconn 256
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:80
default_backend webservers
backend webservers
balance roundrobin
# Poor-man's sticky
# balance source
# JSP SessionID Sticky
# appsession JSESSIONID len 52 timeout 3h
option httpchk
option forwardfor
option http-server-close
server web1 172.28.33.11:80 maxconn 32 check
server web2 172.28.33.12:80 maxconn 32 check
listen admin
bind *:8080
stats enable
EOD
cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.orig
/usr/sbin/service haproxy restart
fi