Route TCP according to payload

if I use haproxy 2.8, this configue is ok:

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

	# Default SSL material locations
	ca-base /etc/ssl/certs
	crt-base /etc/ssl/private

	# See: https://ssl-config.mozilla.org/#server=haproxy&server-version=2.0.3&config=intermediate
        ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
        ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
        ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets

defaults
	log	global
	mode	http
	option	httplog
	option	dontlognull
        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 tcp-in
    bind *:48202
    mode tcp
    option tcplog
    
    tcp-request inspect-delay 5s
    # tcp-request content accept if TRUE
    tcp-request content capture payload(0,9) len 9
    log-format %[capture.req.hdr(0)]
    
    
    # tcp-request content accept if { payload(0,9) -m bin 474554202f766d686b302f }
    # tcp-request content accept if { payload(0,8) -m bin 474554202f737461 }

    # 根据检查结果将请求分配到不同的后端
    # use_backend hell-backend if { payload(0,11) -m bin 474554202f766d686b302f }
    use_backend hell-backend if { payload(0,8) -m bin 474554202f766d68 }
    use_backend haproxy-http-backend if { payload(0,8) -m bin 474554202f737461 }

    default_backend default-backend

backend hell-backend
    mode tcp
    server server1 38.207.173.10:42441 check

backend haproxy-http-backend
    mode tcp
    server default-server 127.0.0.1:38202 check
    
backend default-backend
    mode tcp
    server default-server2 127.0.0.1:48200 check

in version 3.0, the log-format %[capture.req.hdr(0)] is wrong, and the log says:haproxy[95097]: [ALERT] (95097) : config : Parsing [/etc/haproxy/haproxy.cfg:46]: failed to parse log-format : logformat expression not usable here (at least one node depends on HTTP mode).

If I remove the comment sign of # tcp-request content accept if TRUE, haproxy doesn’t work.

I guess the error is telling you you can’t capture a HTTP header in tcp mode. No idea why was this working in version 2.8 at all.