Skip to content

Commit 784dd68

Browse files
committed
Fix HAProxy TLS passthrough failure caused by IPv6 resolution
do-resolve returned AAAA records from external DNS, causing set-dst to overwrite the destination with an unreachable IPv6 address. This also caused use_backend to re-evaluate the dst ACL after set-dst modified it, misrouting TLS connections to ip_passthrough. - Add ipv4 preference to do-resolve to avoid unreachable IPv6 destinations - Store is_dns_routed state in a variable before set-dst modifies dst - Use the stored variable in use_backend instead of re-evaluating dst ACL
1 parent f4108ca commit 784dd68

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

docker/files/haproxy.cfg.template

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ frontend outbound_proxy
3535

3636
# ACL: DNS-routed vs IP direct
3737
acl is_dns_routed dst 172.20.0.1
38+
# Store DNS-routed state in variable (before set-dst may modify dst)
39+
tcp-request content set-var(sess.dns_routed) str(true) if is_dns_routed
3840

3941
# ACL: TLS/SNI
4042
acl is_tls req.ssl_hello_type 1
@@ -76,7 +78,7 @@ frontend outbound_proxy
7678
# ---------------------------------------------------------
7779
# 4. TLS DNS resolution, destination override & accept
7880
# ---------------------------------------------------------
79-
tcp-request content do-resolve(sess.actual_ip,my_dns) var(sess.sni) if is_tls has_sni
81+
tcp-request content do-resolve(sess.actual_ip,my_dns,ipv4) var(sess.sni) if is_tls has_sni
8082
tcp-request content set-var(sess.reason) str(dns-failed) if is_tls has_sni ! { var(sess.actual_ip) -m found }
8183
tcp-request content reject if is_tls has_sni ! { var(sess.actual_ip) -m found }
8284
tcp-request content set-dst var(sess.actual_ip) if is_tls has_sni
@@ -87,7 +89,7 @@ frontend outbound_proxy
8789
# 5. Non-TLS DNS-routed → HTTP backend
8890
# ---------------------------------------------------------
8991
# Routing
90-
use_backend ip_passthrough if !is_dns_routed
92+
use_backend ip_passthrough if !{ var(sess.dns_routed) -m found }
9193
use_backend tls_passthrough if is_tls
9294
default_backend http_filter_backend
9395

@@ -128,7 +130,7 @@ backend http_filter_backend
128130
http-request deny deny_status 403 content-type "text/plain" string "Blocked by egress proxy" if !is_http_allowed
129131

130132
# DNS resolution & destination override
131-
http-request do-resolve(txn.actual_ip,my_dns) var(txn.host_only)
133+
http-request do-resolve(txn.actual_ip,my_dns,ipv4) var(txn.host_only)
132134
http-request set-var(sess.reason) str(dns-failed) if ! { var(txn.actual_ip) -m found }
133135
http-request deny deny_status 503 content-type "text/plain" string "DNS Resolution Failed" if ! { var(txn.actual_ip) -m found }
134136

0 commit comments

Comments
 (0)