solar/resources/haproxy_config/templates/haproxy.cfg

60 lines
1.4 KiB
INI

global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 4096
# tune.ssl.default-dh-param 2048
pidfile /var/run/haproxy.pid
user haproxy
group haproxy
daemon
stats socket /var/run/haproxy.stats level admin
# ssl-default-bind-options no-sslv3 # ubuntu 14.04 have too old haproxy
defaults
log global
mode http
option redispatch
option httplog
option dontlognull
option forwardfor
timeout connect 5000
timeout client 50000
timeout server 50000
#frontend default_frontend
# bind 0.0.0.0:80
# default_backend default_service
#backend default_service
# balance roundrobin
{% for service in haproxy_services %}
listen {{ service['name'] }} 0.0.0.0:{{ service['listen_port'] }}
{% if service['protocol'] == 'http' %}
mode http
stats enable
stats uri /haproxy?stats
stats realm Strictly\ Private
stats auth A_Username:YourPassword
stats auth Another_User:passwd
balance roundrobin
option httpclose
option forwardfor
{% for server in service['servers'] %}
server {{ server['name'] }} {{ server['ip'] }}:{{ server['port'] }} check
{% endfor %}
{% elif service['protocol'] == 'tcp' %}
# tcp there
mode tcp
mode tcp
option tcpka
option srvtcpka
balance leastconn
{% for server in service['servers'] %}
server {{ server['name'] }} {{ server['ip'] }}:{{ server['port'] }} check
{% endfor %}
{% endif %}
{% endfor %}