Re: Dynamic backend routing base on header

2016-01-18 Thread Jonathan Matthews
On 17 January 2016 at 17:54, Michel Blanc  wrote:
> Dear all,
>
> I am trying to get haproxy routing to a specific server if a header
> (with the server nickname) is set.

Can you adapt 
http://blog.haproxy.com/2015/01/26/web-application-name-to-backend-mapping-in-haproxy/
to achieve what you want?

J



Dynamic backend routing base on header

2016-01-17 Thread Michel Blanc
Dear all,

I am trying to get haproxy routing to a specific server if a header
(with the server nickname) is set.

My first guess was that the following config snipped would do it:

  backend ...
acl force_backend req.hdr(X-Want-Backend) -m found
use_server %[req.hdr(X-Want-Backend)] if force_backend

But this is rejected by HAproxy (version 1.5.14)

  unable to find server '%[req.hdr(X-Want-Backend)]' referenced in a
'use-server' rule

Can this be done ? I would like to avoid the "long" alternative where
each server is explicitly listed.

If yes, what happens at run time when a value that doesn't map to a real
server is passed in the header ?

Thanks !

M
-- 
Michel Blanc
{ :github => "@leucos", :twitter => "@b9m", :gpg => "0X24B35C22" }