76 lines
2.1 KiB
Plaintext
76 lines
2.1 KiB
Plaintext
|
global
|
||
|
log fd@2 local2
|
||
|
chroot /var/lib/haproxy
|
||
|
pidfile /var/run/haproxy.pid
|
||
|
maxconn 4000
|
||
|
user haproxy
|
||
|
group haproxy
|
||
|
stats socket /var/lib/haproxy/stats expose-fd listeners
|
||
|
master-worker
|
||
|
|
||
|
resolvers docker
|
||
|
nameserver dns1 127.0.0.11:53
|
||
|
resolve_retries 3
|
||
|
timeout resolve 1s
|
||
|
timeout retry 1s
|
||
|
hold other 10s
|
||
|
hold refused 10s
|
||
|
hold nx 10s
|
||
|
hold timeout 10s
|
||
|
hold valid 10s
|
||
|
hold obsolete 10s
|
||
|
|
||
|
defaults
|
||
|
timeout connect 10s
|
||
|
timeout client 30s
|
||
|
timeout server 30s
|
||
|
log global
|
||
|
monitor-uri /_haproxy_health_check
|
||
|
timeout http-keep-alive {{ haproxy_global_keepalive_timeout }}
|
||
|
timeout connect {{ haproxy_connect_timeout }}
|
||
|
timeout client {{ haproxy_client_timeout }}
|
||
|
timeout server {{ haproxy_server_timeout }}
|
||
|
timeout check {{ haproxy_check_timeout }}
|
||
|
timeout http-request 10s # slowloris protection
|
||
|
default-server inter 3s fall 2 rise 2 slowstart 60s
|
||
|
|
||
|
# Needed to preserve the stick tables
|
||
|
peers mypeers
|
||
|
peer local_haproxy 127.0.0.1:1024
|
||
|
|
||
|
frontend http
|
||
|
|
||
|
bind *:{{ haproxy_default_port }}
|
||
|
|
||
|
mode http
|
||
|
option http-keep-alive
|
||
|
|
||
|
{% for srv in haproxy_docker_swarm_additional_services %}
|
||
|
use_backend {{ srv.acl_name }}_bck if { {{ srv.acl_rule }} }
|
||
|
{% endfor %}
|
||
|
|
||
|
|
||
|
#
|
||
|
# Backends
|
||
|
#
|
||
|
|
||
|
{% for srv in haproxy_docker_swarm_additional_services %}
|
||
|
backend {{ srv.acl_name }}_bck
|
||
|
mode http
|
||
|
option httpchk
|
||
|
balance {{ srv.balance_type | default('roundrobin') }}
|
||
|
{% if srv.http_check_enabled is defined and srv.http_check_enabled %}
|
||
|
http-check send {{ srv.http_check }}
|
||
|
http-check expect {{ srv.http_check_expect }}
|
||
|
{% endif %}
|
||
|
{% if srv.stick_sessions %}
|
||
|
{% if srv.stick_on_cookie %}
|
||
|
cookie {{ srv.stick_cookie }}
|
||
|
{% else %}
|
||
|
stick on src
|
||
|
stick-table {{ srv.stick_table }}
|
||
|
{% endif %}
|
||
|
{% endif %}
|
||
|
server-template {{ srv.service_name }}- {{ srv.service_replica_num }} {{ srv.stack_name }}_{{ srv.service_name }}:{{ srv.service_port }} {{ srv.backend_options | default('') }} check resolvers docker init-addr libc,none
|
||
|
{% endfor %}
|