Hi Joe,

On Mon, Feb 18, 2019 at 05:48:09PM +0000, Joe K wrote:
> https://github.com/haproxy/haproxy/blob/3d95717b58be0902078e0693e383bc32ea3a715a/src/proxy.c#L714
> seems like it's not possible, haproxy seems to be using `strcmp` without
> expanding what's inside %[]. I wonder if it would be useful to anyone
> beside me?
> 
> On Mon, Feb 18, 2019 at 5:25 PM Joe K <[email protected]> wrote:
> 
> > Hello everyone!
> >
> >
> > I wonder if there is a way to use %[...] syntax in use-server directives.
> >
> >
> > backend be_template
> >   server-template websrv 1-100 localhost:6666 check disabled
> >   use-server
> > %[req.hdr(host),lower,map_dom(/usr/local/etc/haproxy/domain2server.map,websrv0)]
> > if { req.hdr(host),lower,map_dom(/usr/local/etc/haproxy/domain2server.map)
> > -m found }
> >
> > Right now, using the above makes haproxy fail at startup with the
> > following error:
> >
> >
> > haproxy_1  | [ALERT] 048/161559 (1) : config : backend 'be_template' :
> > unable to find server
> > '%[req.hdr(host),lower,map_dom(/usr/local/etc/haproxy/domain2server.map,websrv0)]'
> > referenced in a 'use-server' rule.
> > haproxy_1  | [ALERT] 048/161559 (1) : Fatal errors found in configuration.
> >
> >
> > Just in case, I've also asked the same question on the forum:
> > https://discourse.haproxy.org/t/in-use-server/3529
> >

Indeed it's not possible to parse a log-format string there. 

However, you can set dynamically the destination IP with 'http-request set-dst'
and '0.0.0.0:0' as a server address. That's an ugly trick and that might be
difficult to read logs and statistics when doing it because it will use the
same server.

-- 
William Lallemand

Reply via email to