Modifié par Julien EYMERY le 2015/09/03 09:42

Afficher les derniers auteurs
1 La mise en cluster s'effectue au travers d'un loadbalancer.
2
3 Exemple d'utilisation de HaProxy sous plateforme Linux.
4
5
6 Récupération de la version de HaProxy et compilation avec OpenSsl et Deflate
7
8
9 {{code language="bash" language="bash"}}
10 yum install gcc
11 yum install openssl
12 yum install openssl-devel
13 wget http://haproxy.1wt.eu/download/1.5/src/devel/haproxy-1.5-dev21.tar.gz
14 tar -xzf haproxy-1.5-dev21.tar.gz
15 cd haproxy-1.5-dev21
16 make clean
17 make TARGET=linux26 USE_ZLIB=yes USE_OPENSSL=1
18 make install
19 {{/code}}
20
21
22
23 Fichier de configuration haproxy.cfg
24
25
26
27 {{code language="none"}}
28 #---------------------------------------------------------------------
29 # Example configuration for a possible web application. See the
30 # full configuration options online.
31 #
32 #
33 #
34 #---------------------------------------------------------------------
35 #---------------------------------------------------------------------
36 # Global settings
37 #---------------------------------------------------------------------
38 global
39 # to have these messages end up in /var/log/haproxy.log you will
40 # need to:
41 #
42 # 1) configure syslog to accept network log events. This is done
43 # by adding the '-r' option to the SYSLOGD_OPTIONS in
44 # /etc/sysconfig/syslog
45 #
46 # 2) configure local2 events to go to the /var/log/haproxy.log
47 # file. A line like the following can be added to
48 # /etc/sysconfig/syslog
49 #
50 # local2.* /var/log/haproxy.log
51 #
52 log 127.0.0.1 local2
53 chroot /var/lib/haproxy
54 pidfile /var/run/haproxy.pid
55 maxconn 4000
56 user haproxy
57 group haproxy
58 daemon
59 # turn on stats unix socket
60 stats socket /var/lib/haproxy/stats
61 #---------------------------------------------------------------------
62 # common defaults that all the 'listen' and 'backend' sections will
63 # use if not designated in their block
64 #---------------------------------------------------------------------
65 defaults
66 mode http
67 log global
68 option httplog
69 option dontlognull
70 option http-server-close
71 option forwardfor except 127.0.0.0/8
72 option redispatch
73 retries 3
74 timeout http-request 10s
75 timeout queue 1m
76 timeout connect 10s
77 timeout client 1m
78 timeout server 1m
79 timeout http-keep-alive 10s
80 timeout check 10s
81 maxconn 3000
82 frontend http-in
83 bind *:80
84 timeout client 86400000
85 # begin XSS protection
86 rspadd X-Frame-Options:\ DENY
87 # end XSS protection
88 default_backend ws
89 backend ws
90 balance leastconn
91 compression algo gzip
92 compression type text/html text/xml text/css text/plain application/json application/javascript
93 cookie WagonNodeId prefix indirect nocache
94 timeout server 3600s
95 server ws1 192.168.136.159:81 check cookie ws1
96 server ws2 192.168.136.160:81 check cookie ws2
97
98 frontend https-in
99 bind 0.0.0.0:443 ssl crt /etc/ssl/cert.key_pem
100 timeout client 86400000
101 reqadd X-Forwarded-Proto:\ https
102 rspadd X-Frame-Options:\ DENY
103 default_backend wss
104 backend wss
105 balance leastconn
106 compression algo gzip
107 compression type text/html text/xml text/css text/plain application/json application/javascript
108 cookie WagonNodeId prefix indirect nocache
109 timeout server 3600s
110 server wss1 192.168.136.159:82 check cookie wss1
111 server wss2 192.168.136.160:82 check cookie wss2
112 listen stats :81
113 compression algo gzip
114 compression type text/html text/plain
115 mode http
116 stats enable
117 stats hide-version
118 # stats realm Haproxy\ Statistics
119 stats uri /
120 stats refresh 5s
121 # stats auth Username:Password
122 {{/code}}
123