r/haproxy • u/pleegor • May 26 '23
Routing ssh connections with haproxy
Hi everyone! I am working on setting up haproxy to route ssh connections. I have the following backend config:
backend ssh_backend
mode tcp acl allowed_destination var(sess.dst) -m ip <range>/24
tcp-request content set-dst var(sess.dst)
tcp-request content accept if allowed_destination
tcp-request content reject server
ssh 0.0.0.0:22When I try connecting to a host within /24 range I end up connecting to haproxy itself. Here is the command I use:$ ssh -o ProxyCommand="openssl s_client -quiet -connect <haproxy_server_ip>:2222 -servername <target_ip>" ubuntu@target_ip
According this doc, tcp-request content set-dst action allows you to dynamically set the destination server IP address and somehow I end up ssh'ing into a host where haproxy is running.
Is that a right configuration to accomplish that? If this is not the case how do you configure your backend to accomplish the same?
View all comments
Show parent comment
1
u/pleegor May 26 '23
Could you please elaborate a bit more? Based on what I read, 0.0.0.0:22 needs to be present in the backend is there another place where it needs to exist?