NOTE: It is important to note that the responses will be limited to a certain size defined by the global "tune.chksize" option, which defaults to 16384 bytes.
]]>
+
+
+ healthcheck.tcp_matchType
+
+ dropdown
+
+
+
+ healthcheck.tcp_negate
+
+ checkbox
+
+
+
+ healthcheck.tcp_matchValue
+
+ text
+
+
+
+
header
diff --git a/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.xml b/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.xml
index b41478f25..b81c1ba06 100644
--- a/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.xml
+++ b/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.xml
@@ -729,6 +729,29 @@
N
+
+ 0
+ N
+
+
+ N
+
+
+ N
+ string
+
+ test the exact string match in the response buffer [default]
+ test a regular expression on the response buffer
+ test the exact string in its hexadecimal form matches in the response buffer
+
+
+
+ 0
+ N
+
+
+ N
+ 165535
diff --git a/net/haproxy/src/opnsense/service/templates/OPNsense/HAProxy/haproxy.conf b/net/haproxy/src/opnsense/service/templates/OPNsense/HAProxy/haproxy.conf
index a799f4175..cd4c4fe8e 100644
--- a/net/haproxy/src/opnsense/service/templates/OPNsense/HAProxy/haproxy.conf
+++ b/net/haproxy/src/opnsense/service/templates/OPNsense/HAProxy/haproxy.conf
@@ -670,7 +670,28 @@ backend {{backend.name}}
{% if healthcheck_data.type|default("") == "" %}
{% set healthcheck_enabled = '0' %}
{% elif healthcheck_data.type == 'tcp' %}
-{# # TCP check does not require additional options #}
+{# # custom TCP health check option #}
+{% if healthcheck_data.tcp_enabled|default("") == '1' %}
+{# # validate options: both must not be disabled at the same time #}
+{% if healthcheck_data.tcp_sendValue|default("") == "" and healthcheck_data.tcp_matchValue|default("") == "" %}
+ # ERROR: invalid custom TCP health check, missing "sendValue" or "matchValue"
+{% else %}
+{% set healthcheck_customtcp = [] %}
+{% do healthcheck_customtcp.append('send ' ~ healthcheck_data.tcp_sendValue) if healthcheck_data.tcp_sendValue|default("") != "" %}
+{% if healthcheck_data.tcp_matchValue|default("") != "" %}
+{% do healthcheck_customtcp.append('expect ' ~ healthcheck_data.tcp_matchType) %}
+{% if healthcheck_data.tcp_negate == '1' and healthcheck_data.tcp_matchType|default("") != 'binary' %}
+{% do healthcheck_customtcp.append('!') %}
+{% endif %}
+{% do healthcheck_customtcp.append(healthcheck_data.tcp_matchValue) %}
+{% endif %}
+{# # XXX: some values (send/match) must be properly escaped (whitespace) #}
+{# # TODO: add support for multiple send/expect steps #}
+ option tcp-check
+ tcp-check connect
+ tcp-check {{healthcheck_customtcp|join(' ')}}
+{% endif %}
+{% endif %}
{% elif healthcheck_data.type == 'http' %}
{% do healthcheck_options.append('httpchk') %}
{# # HTTP method must be uppercase #}