HAProxy community

TCP Traffic redirect by domainname


Hello, i have a gameserver. Multiple game instance working on same server with different ports.

for example
game 1 : ip:20001
game 2 : ip:20002

games deault port is : 2000. if anyone want to connect to this servers they must we write a port after ip because it’s not working on default port.

Can i redirect this traffic to different ports by domain name.

For example HAProxy listen game’s default port 2000.

If client trying to connect abc.com:2000 haproxy redirect this traffic to
if try do abcd.com:2000 haproxy redirect this traffic to

Is it possible, if yes how can i do it ?

Thank you.


Only with HTTP or HTTPS. Not with a proprietary protocol (like a game server), unless:

  • the client talks first
  • that first packet contains the hostname on a fixed offset which you can match with payload or payload_lv [1]

Also most of the game servers actually use UDP for the game synchronization, and only use TCP for setup and things like chats or statistics.

[1] https://cbonte.github.io/haproxy-dconv/1.7/configuration.html#7.3.5-payload


We could say that with TLS you could achieve the desired setup, right? As the client would advertise the desired host via SNI.


That depends on the application. A browser will always add SNI to the TLS hello, but that doesn’t mean other applications do the same. They may or may not.


Got it, that makes sense.

I took a look at the RFCs again, I forgot that it is an extension that may be used.

Thanks, Lukas!