On Thu, Nov 15, 2018 at 1:36 AM Aleksandar Lazic <al-hapr...@none.at> wrote:

> Hi Vijay.
>
> Am 14.11.2018 um 10:14 schrieb Vijay Bais:
> > Hello Aleksandar,
> >
> > We already considered using haproxy maps but we still have to define N
> backends
> > for corresponding N keys in the map file.
> > I'm looking more at an implementation with single backend definition
> with the
> > server options as placeholders.
> >
> > Ex. Using maps would look something like this
> >
> >     frontend nat
> >         bind *:10000
> >         use_backend %[req.hdr(X-MyHeader), map(/etc/haproxy/my.map)]
> >
> >     backend example1.com
> >         server myserver1 example1.com:80 source 10.0.0.1
> >
> >     backend example2.com
> >         server myserver2 example2.com:80 source 10.0.0.2
> >
> >     backend example3.com
> >         server myserver3 example3.com:80 source 10.0.0.3
> >
> >
> >
> > Whereas, we are looking for something like below
> >
> >
> >     frontend nat
> >         bind *:10000
> >         default_backend generic
> >
> >     backend generic
> >         server myserver %[req.hdr(X-MyHeader)] source %[dst]
>
> Ah now concrete examples ;-)
>
> Maybe you can use the server template?!
>
> https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#4-server-template
>
> So you would like to have something like this, is this possible, I don't
> think so?
>
> backend generic
>   server-template myserver 1-3 %[req.hdr(X-MyHeader)]:80 check source
> 0.0.0.0
> usesrc %[dst]
>
> Which version of HAProxy do you use?
>
> haproxy -vv
>
> > Thanks,
> > Vijay
>
> Regards
> Aleks
>
> > On Wed, Nov 14, 2018 at 1:39 PM Aleksandar Lazic <al-hapr...@none.at
> > <mailto:al-hapr...@none.at>> wrote:
> >
> >     Hi.
> >
> >     Am 14.11.2018 um 08:46 schrieb Vijay Bais:
> >     > Hello,
> >     >
> >     > We have a requirement wherein a single generic backend with server
> options
> >     > configured as placeholders, which will resolve on the fly or at
> runtime.
> >     >
> >     > Currently, we have to define multiple backends (has to be
> hardcoded) and
> >     select
> >     > them using the /use_backend/ keyword.
> >     >
> >     > Kindly help us with this generic backend implementation in HAProxy
> and let us
> >     > know if its possible OR any alternative way that this can be
> achieved.
> >
> >     Maybe you can use maps for your requirement.
> >
> >     https://www.haproxy.com/blog/introduction-to-haproxy-maps/
> >
> >     As an example can you take a look at the openshift router template
> ;-)
> >
> >
> https://github.com/openshift/origin/blob/master/images/router/haproxy/conf/haproxy-config.template#L201-L202
> >
> >     > Thank you in advance,
> >     > Vijay B
> >
> >     Regards
> >     Aleks
>

You will need something dynamic like described here
https://www.haproxy.com/blog/haproxy-and-consul-with-dns-for-service-discovery/

Reply via email to