haproxy-wi/app/scripts/ansible/roles/haproxy/templates/haproxy.cfg.j2

63 lines
1.9 KiB
Django/Jinja

global
log 127.0.0.2 local0
log 127.0.0.1 local1 notice
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
stats socket *:{{SOCK_PORT}} level admin
stats socket /var/run/haproxy.sock mode 600 level admin
server-state-file {{STAT_FILE}}
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
listen stats
bind *:{{STAT_PORT}}
http-request use-service prometheus-exporter if { path /metrics }
stats enable
stats uri /stats
stats realm HAProxy-04\ Statistics
stats auth {{STATS_USER}}:{{STATS_PASS}}
stats admin if TRUE
{% if M_OR_S != 'None' %}
peers default_peers
{% if M_OR_S == 'master' %}
peer {{ ansible_hostname }} {{MASTER}}:10000
{% for slave in slaves %}
peer slave_lb {{slave}}:10000
{% endfor %}
{% else %}
peer master_lb {{MASTER}}:10000
{% for slave in slaves %}
peer {{ ansible_hostname }} {{slave}}:10000
{% endfor %}
{% endif %}
{% endif %}
backend per_ip_and_url_rates
stick-table type binary len 8 size 1m expire 24h store http_req_rate(24h) {% if M_OR_S != 'None' %} peers default_peers {% endif %}
backend per_ip_rates
stick-table type ip size 1m expire 24h store gpc0,gpc0_rate(30s) {% if M_OR_S != 'None' %} peers default_peers {% endif %}