global

pidfile /var/run/haproxy.pid
log 127.0.0.1 local0 info
user root

defaults

mode http

clitimeout          600000   # maximum inactivity time on the client side
srvtimeout          600000   # maximum inactivity time on the server side
timeout connect     8000     # maximum time to wait for a connection attempt to a server to succeed

stats       enable
stats       auth                  admin:password
stats       uri                     /monitor
stats       refresh 5s
retries               5
option      httpchk       GET /status               
option      redispatch
option      httpclose
option      abortonclose
option      forwardfor    

balance roundrobin  # each server is used in turns, according to assigned weight

frontend http

bind :5000
monitor-uri         /haproxy  # end point to monitor HAProxy status (returns 200)

acl acl_api hdr_beg(host) -i api
use_backend backend_api if acl_api

acl acl_front path_reg ^/?
use_backend backend_front if acl_front

default_backend backend_front

backend backend_front

server srv_index 127.0.0.1:4000

backend backend_api

server srv_donors 127.0.0.1:4001