How to configure HAProxy to route by port without using multiple frontend or listeners
33,864
Using a single frontend and multiplexing to the backends is indeed possible. You will be required to add one backend section per backend server, e.g.
backend JabberD1
tcp-check connect
tcp-check send PING\r\n
tcp-check expect string +PONG
server Server1ZoneD 10.60.30.209:80 check
backend JabberE1
tcp-check connect
tcp-check send PING\r\n
tcp-check expect string +PONG
server Server1ZoneE 10.60.47.4:80 check
etc.
In your frontend, split the traffic like this
acl d1 dst_port 5222
use_backend JabberD1 if d1
etc.
Related videos on Youtube
Author by
Developr
Updated on September 18, 2022Comments
-
Developr over 1 year
I am trying to configure Haproxy v1.5 for Jabber connections which run on several ports on the same IP. To keep the configuration as simple as possible, I would like to use a single frontend and one or more backends. Is there a way for me to pass the source port to the backend or to use a ACL to route to a different backend based on port?
frontend Jabber_IN bind 10.60.0.12:5222 name port5222 bind 10.60.0.12:5223 name port5223 bind 10.60.0.12:9090 name port9090 bind 10.60.0.12:9091 name port9091 bind 10.60.0.12:7070 name port7070 bind 10.60.0.12:7443 name port7443 bind 10.60.0.12:5229 name port5229 mode tcp option tcplog option tcpka timeout client 60m timeout server 60m timeout http-keep-alive 1m default_backend Jabber backend Jabber tcp-check connect tcp-check send PING\r\n tcp-check expect string +PONG server Server1ZoneD 10.60.30.209:80 check server Server1ZoneE 10.60.47.4:80 check server Server2ZoneD 10.60.17.8:80 check server Server2ZoneE 10.60.45.219:80 check