Friday, January 28, 2011

HAProxy Per server URL rewriting in the backend (reqirep?)

Is it possible to have a path appended (like the requirep below) but on a per server basis ? I can't see how it is possible in 1.3 or 1.4. There is redir, but redir does a HTTP redirect, not what I need.

backend something.abc.com 
    ...
  reqirep ^([^\ \t])(.*)[\ \t]/(.*) \1\2\ /businessGov/pad/businessgov.html\3
  server node1 someserver1:80 cookie node1  check
  server node1 someserver2:80 cookie node2  check
  • No it's not possible, because the HTTP rewriting is performed before selecting the server. And if the connection to the server failed we'd have to retry on another one, possibly reprocessing what has already been done over and over, which surely is not what you want.

    Keep in mind that haproxy is a load balancer. The servers are then assumed to be doing the same thing and to receive equivalent requests. Otherwise you're more talking about independant farms that could be materialized in distinct backends with distinct rules.

    Michael Neale : yep - on reading the haproxy source I realised that it wouldn't be possible (its pretty neat source !). I was interested as nginx proxying refer to backends via full URL - not via server:port

0 comments:

Post a Comment