HAProxy community

Subdomain reverse proxy

I am hosting several subnets (*.domain.com) using HaProxy. I want to configure all traffic to passthrouth for a domain, whatever port, as long it is for that domain.

internet -> subdomain.domain.com:* -> haproxy -> backendhost.

Is that possible?

Which protocol? HTTP? HTTPS? Every TCP protocol? The backend host is one single destination?

I was referring to all ports/protocols as I had * in the port section of the forwarding argument.

What you can do is forward traffic that haproxy is able to bind to (probably not port 22 for example though), and forward it to the same port to a specific destination IP.

For example:

frontend bindall
 mode tcp
 default_backend back

backend back
 mode tcp
 server s1

You will not be able to match any “domain”, because there is now such thing in a socket (just IP addresses and ports), and by trying to forward arbitrary protocols, by definition neither is in the protocol.

Remember that haproxy is a reverse application layer proxy. It’s not a forwarding proxy and neither it is a NAT gateway. Your requirements very much sound like you are trying to use haproxy for a use-case that it’s not made for.

Thank you for your detailed answer. I will try it.