https://cbonte.github.io/haproxy-dconv/
apt install haproxy
/etc/haproxy/haproxy.cfg
https://www.lisenet.com/2015/setting-up-a-load-balancing-haproxy-cluster-with-keepalived/
frontend lb-kubernetes
mode tcp
bind *:80
reqadd X_Forwarded-Proto:\ http
default_backend kubernetes-nodes
backend kubernetes-nodes
balance source
mode tcp
server rancher-01 192.168.20.157:80 check
server rancher-02 192.168.20.158:80 check
https://www.haproxy.com/blog/how-to-map-domain-names-to-backend-server-pools-with-haproxy/
frontend default
bind :80
# ACL for "example.com" and "www.example.com"
acl ACL_example.com hdr(host) -i example.com www.example.com
use_backend be_example_com if ACL_example.com
# ACL for "example.net"
acl ACL_example.net hdr(host) -i example.net
use_backend be_example_net if ACL_example.net
or
frontend fe_main
bind :80
# If Host header is api.example.com then use
# api.example.com backend
use_backend %[req.hdr(Host),lower]
Please note that the incoming host header variable includes any port explicitly specified, so incoming requests for example.com:6666 would be sent to a backend named backend example.com:6666, which may or may not exist. To strip the port, use:use_backend %[req.hdr(host),lower,word(1,:)]
backend api.example.com
balance roundrobin
server api1 127.0.0.1:8080 check
server api2 127.0.0.1:8081 check
frontend stats
bind *:8404
stats enable
stats uri /stats
stats refresh 10s
stats admin if LOCALHOST
see Loadbalancing