Hi,

On Tue, Feb 01, 2011 at 04:08:43PM -0500, Chase Seibert wrote:
> In this example config, is it possible to insert a custom response
> header, say "X-Backend-Server", with the value of "www1" or "www2"
> depending on which server HAProxy routed to? This would be primarily
> for trouble-shooting purposes. For example, if we suspect that the
> deploy is broken on just one of the web servers.

In very recent version (the yet unreleased 1.4.11), you can do that
with the "srv_id" acl, which allows you to match an ACL based on the
server which processed the request. Thus you can have :

  rspadd X-Backend-Server:\ www1  if { srv_id 1 }
  rspadd X-Backend-Server:\ www2  if { srv_id 2 }

Obviously this will not scale very well but can be useful for trouble
shooting purposes.

Alternatively, you can simply insert a cookie in the response the
usual way, but it will enforce persistence. I've checked and reponse
rewriting is performed before sending persitence cookie so it's not
possible to use a reqdel rule to delete the added cookie. You might
delete all client cookies if it's a static server though.

I've already got demands for adding the server name in requests
(which is very difficult due to redispatches), but I'm realizing
it would be much easier in responses (though it does not serve the
same purpose). Maybe we should simply add an option for that, it
would be just a few lines of code.

Regards,
Willy


Reply via email to