Configs
HAProxy /etc/haproxy/haproxy.cfg global log 127.0.0.1 local2 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid user haproxy group haproxy daemon defaults log global timeout connect 5000ms timeout client 50000ms timeout server 50000ms frontend http_front bind *:80 redirect scheme https code 301 if !{ ssl_fc } mode http frontend stats mode http bind *:8404 stats enable stats uri /stats stats refresh 10s stats auth haproxy:haproxy stats admin if TRUE stats show-modules frontend https_front bind *:443 ssl crt /etc/haproxy/haproxy.pem acl glpi hdr(host) glpi.bagdad.lan acl wiki hdr(host) wiki.bagdad.lan acl zabbix hdr(host) zabbix.bagdad.lan acl host_ha hdr(host) -i ha.bagdad.lan use_backend glpi_backend if glpi use_backend wiki_backend if wiki use_backend zabbix_backend if zabbix use_backend backend_nginxha if host_ha option forwardfor mode http backend backend_nginxha balance roundrobin server ephilates 172.16.96.197:80 check server aloades 172.16.96.198:80 check mode http backend glpi_backend server glpi 172.16.96.196:80 check mode http backend wiki_backend server wiki 172.16.96.194:3000 check mode http backend zabbix_backend server zabbix 172.16.96.51:80 check mode http frontend db_front bind *:3306 mode tcp default_backend db_backend backend db_backend mode tcp server db 172.16.96.37:3306 check Keepalived /etc/keepalived/keepalived.conf | KERES ! Configuration File for keepalived global_defs { } vrrp_script chk_haproxy { script "killall -0 haproxy" # check if haproxy is on interval 2 # check every 2 seconds weight 2 # add 2 points of prio if OK } vrrp_instance haproxy { state MASTER interface ens192 virtual_router_id 51 priority 101 advert_int 1 authentication { auth_type PASS auth_pass G6L7@UgEgz#4RHP2WtU } virtual_ipaddress { 172.16.96.220 } unicast_src_ip 172.16.96.210 # This node unicast_peer { 172.16.96.211 # Other nodes } track_script { chk_haproxy } } /etc/keepalived/keepalived.conf | CYAMITES ! Configuration File for keepalived global_defs { } vrrp_script chk_haproxy { script "killall -0 haproxy" # check if haproxy is running interval 2 # check every 2 seconds weight 2 # add 2 points of prio if OK } vrrp_instance haproxy { state BACKUP interface ens192 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass G6L7@UgEgz#4RHP2WtU } virtual_ipaddress { 172.16.96.220 } unicast_src_ip 172.16.96.211 # This node unicast_peer { 172.16.96.210 # Other nodes } track_script { chk_haproxy } } NGINX /etc/nginx/conf.d/ha.bagdad.lan.conf | EPHILATES server { listen 80; server_name ephilates; server_name ha.bagdad.lan; access_log /var/log/nginx/access_ha.bagdad.lan.log; error_log /var/log/nginx/error_ha.bagdad.lan.log; location / { return 200 "Je suis EPHILATES !"; add_header Content-Type text/plain; } } /etc/nginx/conf.d/ha.bagdad.lan.conf | ALOADES server { listen 80; server_name aloades; server_name ha.bagdad.lan; access_log /var/log/nginx/access_ha.bagdad.lan.log; error_log /var/log/nginx/error_ha.bagdad.lan.log; location / { return 200 "Je suis ALOADES !"; add_header Content-Type text/plain; } } Vérifier l’état des services Vérifier le fonctionnement du roundrobin Rendez-vous sur une machine qui dispose du DNS AD configuré. Ouvrez un invite de commande et tapez la commande suivante : curl -k -H "Host: ha.bagdad.lan" https://172.16.96.220 Relancer la commande plusieurs fois afin de passer d’EPHILATES à ALOADES et ainsi de suite. ...