summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/cephadm/templates/services/ingress/haproxy.cfg.j2
blob: cb84f1d072226f3a55d37a62795d3dcd2d31884a (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# {{ cephadm_managed }}
global
    log         127.0.0.1 local2
    chroot      /var/lib/haproxy
    pidfile     /var/lib/haproxy/haproxy.pid
    maxconn     8000
    daemon
    stats socket /var/lib/haproxy/stats
{% if spec.ssl_cert %}
  {% if spec.ssl_dh_param %}
    tune.ssl.default-dh-param {{ spec.ssl_dh_param }}
  {% endif %}
  {% if spec.ssl_ciphers %}
    ssl-default-bind-ciphers {{ spec.ssl_ciphers | join(':') }}
  {% endif %}
  {% if spec.ssl_options %}
    ssl-default-bind-options {{ spec.ssl_options | join(' ') }}
  {% endif %}
{% endif %}

defaults
    mode                    {{ mode }}
    log                     global
{% if mode == 'http' %}
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout queue           20s
    timeout connect         5s
    timeout http-request    1s
    timeout http-keep-alive 5s
    timeout client          1s
    timeout server          1s
    timeout check           5s
{% endif %}
{% if mode == 'tcp' %}
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout check           10s
{% endif %}
    maxconn                 8000

frontend stats
    mode http
    bind {{ ip }}:{{ monitor_port }}
    bind localhost:{{ monitor_port }}
    stats enable
    stats uri /stats
    stats refresh 10s
    stats auth {{ user }}:{{ password }}
    http-request use-service prometheus-exporter if { path /metrics }
    monitor-uri /health

frontend frontend
{% if spec.ssl_cert %}
    bind {{ ip }}:{{ frontend_port }} ssl crt /var/lib/haproxy/haproxy.pem
{% else %}
    bind {{ ip }}:{{ frontend_port }}
{% endif %}
    default_backend backend

backend backend
{% if mode == 'http' %}
    option forwardfor
    balance static-rr
    option httpchk HEAD / HTTP/1.0
    {% for server in servers %}
    server {{ server.name }} {{ server.ip }}:{{ server.port }} check weight 100
    {% endfor %}
{% endif %}
{% if mode == 'tcp' %}
    mode        tcp
    balance     source
    hash-type   consistent
    {% for server in servers %}
    server {{ server.name }} {{ server.ip }}:{{ server.port }}
    {% endfor %}
{% endif %}