Is it possible to configure HAProxy to resolve hostnames and forward to a certain IP based on the SNI value? I want to configure something like the following:
Client → HAProxy (resolve SNI value) → Forward to resolved IP
I have searched the documentation and forums but it seems that the HAProxy configuration requires one to specify a specific backend with either DNS or IP, but this would not work for my use case as I do not know the backend IP and need to resolve the SNI header to get it.
It seems here you’re searching for a forward proxy functionality, while HAproxy is designed as a reverse proxy: it’s really based on frontend / backend cooperation.
There is also a listen shortcut allowing to specify frontend and backend in one go, but you still need to define the destination of your requests.
However, HAproxy supports multiple SSL certificates, variables and regexes, so if you want to redirect multiple SNIs using only one frontend and multiple backends, you can. Typical scenario:
This is not the case, HAProxy would work as a reverse proxy in this instance, but I need it to resolve a DNS name in order to find the backend address.
For what I understand of the configuration documentation, backends can be configured using a static DNS name + a resolver configuration, but what I am looking for is a way to dynamically configure the DNS name that HAProxy will resolve to find the backend IP addresses.