Skip to content

Commit 05a9072

Browse files
olethanhnesitor
authored andcommitted
HaProxy make SSH routing possible
1 parent b3ed458 commit 05a9072

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

packaging/aleph-vm/etc/haproxy/haproxy-aleph.cfg

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,16 @@ frontend ft_http
8282

8383
# Frontend for SSH and other TCP traffic
8484
frontend ft_ssh
85-
bind :::2222 v4v6
86-
#ssl crt /etc/haproxy/certs/ssl.pem
85+
bind :::2222 v4v6 ssl crt /etc/haproxy/certs/
8786
mode tcp
8887

89-
# For SSH connections, we need a different approach
90-
# For this example, assume connections to port 22 go to fixed backends based on client source
91-
#tcp-request content set-var(sess.dst) ssl_fc_sni
88+
# example ssh command
89+
# /usr/bin/ssh -o ProxyCommand="openssl s_client -quiet -connect echo.agot.be:2222 -servername echo.agot.be" -l ubuntu dummyName
90+
# see https://www.haproxy.com/blog/route-ssh-connections-with-haproxy#route-ssh-connections-with-haproxy
91+
92+
log-format "SSH %ci:%cp %ft %b/%s %Tw/%Tc/%Tt %B %ts %ac/%fc/%bc/%sc/%rc %sq/%bq dst:%[var(txn.sni)] "
93+
tcp-request content set-var(txn.sni) ssl_fc_sni
9294
use_backend bk_ssh
93-
#default_backend bk_default_ssl
9495

9596
# Dynamic backends that will be populated with servers at runtime
9697
backend bk_ssl
@@ -100,8 +101,8 @@ backend bk_ssl
100101
# For HTTPS - Use SNI
101102
acl server_found var(txn.sni),lower,map(/etc/haproxy/https_domains.map) -m found
102103
use-server %[var(txn.sni),lower,map(/etc/haproxy/https_domains.map)] if server_found
103-
use-server fallback_local unless server_found
104-
server fallback_local 127.0.0.1:4443 send-proxy
104+
use-server fallback_local unless server_found
105+
server fallback_local 127.0.0.1:4443 send-proxy
105106

106107
backend bk_ssh
107108
mode tcp

0 commit comments

Comments
 (0)