On Wed, Apr 29, 2020 at 7:49 AM Michal Vala <[email protected]> wrote:

> Hello,
> I would like to do reverse proxy with haproxy so that part of the path
> resolves to the server and I need to do it dynamically, servers are
> created and destroyed on the fly. And I need to do the path rewrite so
> the server part is removed from the path (I can do that with
> http-request set-path %[path,regsub(^/ws-.+\//?,/)] on the backend).
>
> for example 'http://example.com/server-123abc/api/users' requests
> server 'server-123abc' on '/api/users'
>
> Is it possible to do this completely dynamic, without knowing server
> adresses ahead (we generate them dynamically with "random" names) AND
> without restarting haproxy to load new configuration? I was thinking
> about some regex matching, but I don't know how to do dynamic server
> address and if it is somehow possible.
>
> Thanks
>
> --
> Michal Vala
> Software Engineer, Eclipse Che
> Red Hat Czech
>
>
>
Hi Michal,

Yes, you can do this with the HTTP action 'do-resolve', such as:

https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#4.2-http-request%20do-resolve

You can extract whatever information and do a DNS resolution and use the
resulting IP as a destination.

Baptiste

Reply via email to