Serve errorfile in default_backend when mode is tcp

Hi!

I switched from nginx to HAProxy for load balancing because HAProxy does support health-checks (yeah!).

Current config:

global
    log /dev/log    local0
    log /dev/log    local1 notice
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    user haproxy
    group haproxy
    daemon

defaults
    log     global
    mode    http
    option  httplog
    timeout connect 5000
    timeout client  50000
    timeout server  50000
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http

frontend https-local
    bind :443
    option tcplog
    log global
    mode tcp
    use_backend local-default-http2
    default_backend bknd-down

backend local-default-http2
    mode tcp
    balance roundrobin
    option tcplog
    option ssl-hello-chk
    option httpchk HEAD /index.html HTTP/2.0\r\nHost:\ sub.domain.de\r\nUser-Agent:\ HAPROXY-CHECK
    server nginx_http2 sub.domain.de:5009 check check-ssl inter 1000 verify none

backend bknd-down
    # server errorfile?

HAProxy checks every second if the sub.domain.de:5009 server is reachable (I replaced the domain with sub.domain.de). When the server is down (or more the app isn’t running so /index.html can’t be requests) it just see a ‘ERR_CONNECTION_CLOSED’ error in chrome.

I thought I could simply add a default_backend to the frontend which is used when all the other servers available (it’s only one in my example) are down. But that’s not working.

How can I achieve that? When the local-default-http2 backend has no server available show an errorfile.

Thank you very much! :slight_smile: