haproxy.cfg (Source)

global
  log 127.0.0.1 local0
  chroot  /var/lib/haproxy
  daemon
  group  haproxy
  maxconn  4000
  pidfile  /var/run/haproxy.pid
  user  haproxy

defaults
  log  global
  maxconn  4000
  option  redispatch
  retries  3
  timeout  http-request 10s
  timeout  queue 1m
  timeout  connect 10s
  timeout  client 1m
  timeout  server 1m
  timeout  check 10s

listen dashboard_cluster
  bind {{pillar['netprefix']['api']['prefix']}}.{{pillar['netsuffix']['os']}}:443
  bind {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix']['os']}}:443
  balance  source
  option  tcpka
  option  httpchk
  option  tcplog
{% for h in ['ctrl-1', 'ctrl-2', 'ctrl-3'] %}
  server {{h}} {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix'][h]}}:443 check inter 2000 rise 2 fall 5
{% endfor %}

listen galera_cluster
  bind {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix']['os']}}:3306
  balance  source
  option tcp-check
  server ctrl-1 {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix']['ctrl-1']}}:3306 {% if grains['host'] != 'ctrl-1' %}backup{% endif %} check
  server ctrl-2 {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix']['ctrl-2']}}:3306 {% if grains['host'] != 'ctrl-2' %}backup{% endif %} check
  server ctrl-3 {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix']['ctrl-3']}}:3306 {% if grains['host'] != 'ctrl-3' %}backup{% endif %} check

listen glance_api_cluster
  bind {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix']['os']}}:9292
  balance  source
  option  tcpka
  option  httpchk /versions
  option  tcplog
{% for h in ['ctrl-1', 'ctrl-2', 'ctrl-3'] %}
  server {{h}} {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix'][h]}}:9292 check inter 2000 rise 2 fall 5
{% endfor %}

listen glance_registry_cluster
  bind {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix']['os']}}:9191
  balance  source
  option  tcpka
  option  tcplog
{% for h in ['ctrl-1', 'ctrl-2', 'ctrl-3'] %}
  server {{h}} {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix'][h]}}:9191 check inter 2000 rise 2 fall 5
{% endfor %}

listen keystone_admin_cluster
  bind {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix']['os']}}:35357
  balance  source
  option  tcpka
  option  httpchk
  option  tcplog
{% for h in ['ctrl-1', 'ctrl-2', 'ctrl-3'] %}
  server {{h}} {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix'][h]}}:35357 check inter 2000 rise 2 fall 5
{% endfor %}

listen keystone_public_internal_cluster
  bind {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix']['os']}}:5000
  balance  source
  option  tcpka
  option  httpchk
  option  tcplog
{% for h in ['ctrl-1', 'ctrl-2', 'ctrl-3'] %}
  server {{h}} {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix'][h]}}:5000 check inter 2000 rise 2 fall 5
{% endfor %}

listen nova_ec2_api_cluster
  bind {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix']['os']}}:8773
  balance  source
  option  tcpka
  option  tcplog
{% for h in ['ctrl-1', 'ctrl-2', 'ctrl-3'] %}
  server {{h}} {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix'][h]}}:8773 check inter 2000 rise 2 fall 5
{% endfor %}

listen nova_compute_api_cluster
  bind {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix']['os']}}:8774
  balance  source
  option  tcpka
  option  httpchk
  option  tcplog
{% for h in ['ctrl-1', 'ctrl-2', 'ctrl-3'] %}
  server {{h}} {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix'][h]}}:8774 check inter 2000 rise 2 fall 5
{% endfor %}

listen nova_metadata_api_cluster
  bind {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix']['os']}}:8775
  balance  source
  option  tcpka
  option  tcplog
{% for h in ['ctrl-1', 'ctrl-2', 'ctrl-3'] %}
  server {{h}} {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix'][h]}}:8775 check inter 2000 rise 2 fall 5
{% endfor %}

listen cinder_api_cluster
  bind {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix']['os']}}:8776
  balance  source
  option  tcpka
  option  httpchk
  option  tcplog
{% for h in ['ctrl-1', 'ctrl-2', 'ctrl-3'] %}
  server {{h}} {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix'][h]}}:8776 check inter 2000 rise 2 fall 5
{% endfor %}

listen ceilometer_api_cluster
  bind {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix']['os']}}:8777
  balance  source
  option  tcpka
  option  tcplog
{% for h in ['ctrl-1', 'ctrl-2', 'ctrl-3'] %}
  server {{h}} {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix'][h]}}:8777 check inter 2000 rise 2 fall 5
{% endfor %}

listen nova_vncproxy_cluster
  bind {{pillar['netprefix']['api']['prefix']}}.{{pillar['netsuffix']['os']}}:6080
  bind {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix']['os']}}:6080
  balance  source
  option  tcpka
  option  tcplog
{% for h in ['ctrl-1', 'ctrl-2', 'ctrl-3'] %}
  server {{h}} {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix'][h]}}:6080 check inter 2000 rise 2 fall 5
{% endfor %}

listen neutron_api_cluster
  bind {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix']['os']}}:9696
  balance  source
  option  tcpka
  option  httpchk
  option  tcplog
{% for h in ['ctrl-1', 'ctrl-2', 'ctrl-3'] %}
  server {{h}} {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix'][h]}}:9696 check inter 2000 rise 2 fall 5
{% endfor %}

listen swift_proxy_cluster
  bind {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix']['os']}}:8080
  balance  source
  option  tcplog
  option  tcpka
{% for h in ['ctrl-1', 'ctrl-2', 'ctrl-3'] %}
  server {{h}} {{pillar['netprefix']['srv']['prefix']}}.{{pillar['netsuffix'][h]}}:8080 check inter 2000 rise 2 fall 5
{% endfor %}

## HAProxy stats web gui.
listen stats 
	bind {{pillar['netprefix']['api']['prefix']}}.{{pillar['netsuffix'][grains['host']]}}:9000
	mode http
	stats enable
	stats uri /haproxy_stats  
	stats realm HAProxy\ Statistics 
	stats auth haproxy:haproxy
	stats admin if TRUE