haproxy/templates/haproxy.cfg.j2
2026-04-17 13:34:09 +02:00

112 lines
2.7 KiB
Django/Jinja

# global
global
log {{ haproxy_global.log }}
chroot {{ haproxy_global.chroot }}
pidfile {{ haproxy_global.pidfile }}
maxconn {{ haproxy_global.maxconn }}
group {{ haproxy_global.group }}
user {{ haproxy_global.user }}
{%- if haproxy_global.daemon %}
daemon
{%- endif %}
stats socket {{ haproxy_global.stats_socket }}
# default settings
defaults
log {{ haproxy_defaults.log }}
mode {{ haproxy_defaults.mode }}
option {{ haproxy_defaults.option }}
timeout check {{ haproxy_defaults.timeout_check }}
timeout connect {{ haproxy_defaults.timeout_connect }}
timeout client {{ haproxy_defaults.timeout_client }}
timeout server {{ haproxy_defaults.timeout_server }}
{%- if haproxy_stats.enabled %}
# stats
listen stats
bind {{ haproxy_stats.bind }}
mode {{ haproxy_stats.mode }}
stats enable
stats uri {{ haproxy_stats.uri }}
{%- if haproxy_stats.show_node %}
stats show-node
{%- endif %}
stats refresh {{ haproxy_stats.refresh }}
stats auth {{ haproxy_stats.auth }}
{%- endif %}
{%- for frontend in haproxy_frontends %}
# frontend - {{ frontend.name }}
frontend {{ frontend.name }}
bind {{ frontend.bind }}
{%- if frontend.mode is defined %}
mode {{ frontend.mode }}
{%- endif %}
{%- if frontend.options is defined %}
{%- for option in frontend.options %}
{{ option }}
{%- endfor %}
{%- endif %}
default_backend {{ frontend.default_backend }}
{%- endfor %}
{%- for backend in haproxy_backends %}
# backend {{ backend.name }}
backend {{ backend.name }}
{%- if backend.balance is defined %}
balance {{ backend.balance }}
{%- endif %}
{%- if backend.hash_type is defined %}
hash-type {{ backend.hash_type }}
{%- endif %}
{%- if backend.mode is defined %}
mode {{ backend.mode }}
{%- endif %}
{%- if backend.stick_table is defined %}
stick-table {{ backend.stick_table }}
{%- endif %}
{%- if backend.acls is defined %}
{%- for acl in backend.acls %}
acl {{ acl }}
{%- endfor %}
{%- endif %}
{%- if backend.tcp_request is defined %}
{%- for tcp_req in backend.tcp_request %}
tcp-request {{ tcp_req }}
{%- endfor %}
{%- endif %}
{%- if backend.tcp_response is defined %}
{%- for tcp_resp in backend.tcp_response %}
tcp-response {{ tcp_resp }}
{%- endfor %}
{%- endif %}
{%- if backend.stick is defined %}
{%- for stick in backend.stick %}
stick {{ stick }}
{%- endfor %}
{%- endif %}
{%- if backend.options is defined %}
{%- for option in backend.options %}
{{ option }}
{%- endfor %}
{%- endif %}
{%- for server in backend.servers %}
server {{ server.name }} {{ server.address }}{% if server.send_proxy | default(false) %} send-proxy{% endif %}{% if server.check | default(false) %} check{% endif %}{% if server.extra_params is defined %} {{ server.extra_params }}{% endif %}
{%- endfor %}
{%- endfor %}