Re: Set header with value extracted from path

2014-12-04 Thread Baptiste
On Thu, Dec 4, 2014 at 12:09 AM, Ryan rnidef...@gmail.com wrote:
 When I received URL's with the following format:

 /1/a/b/c

 I rewrite the URL removing the digit like so:

 /v2.0.0/a/b/c

 And I need to set a header with the value of the digit I replaced, i.e.:

 X-ID: 1

 Is it possible to do this within haproxy? I am able to reqrep the original
 url, and set an ACL to be used with an http-request add-header directive,
 but I dont know how to extract the url value and either save it for use in
 the add-header, or to write a format string in the add-header directive that
 will do this.

 I'm playing around with something like this but not having much luck:

 acl url_id path_reg ^/([0-9]+)/.*$
 http-request add-header X_ID %[path_reg(^/([0-9]+)/.*$)] if url_id

 Any ideas?

 Thanks,
 Ryan



Hi Rian,

Either there is a bug in the code or the documentation is inacurate,
in chapter 7.3.6 HTTP samples.
The document says we can fetch content using a sample called path and
all its derivatives, including path_reg.

Actually, when I add the following in my conf:
  http-request set-header X-blah %[path_reg .*]
I have a configuration parsing error because of the slash.
When I backslash it:
 http-request set-header X-blah %[path_reg\ .*]
The configuration is valid (from a syntax point of view) but HAProxy
doesn't do anything.


So in your case, I would do this for now:
 acl url_id path_reg ^/([0-9]+)/.*$
 http-request set-header X_ID %[path] if url_id
 http-request replace-value X_ID ^/([0-9]+)/.*$ \1 if { req.hdr(X_ID) -m found }

should do the trick.

Baptiste



eliminate per-server queuing?

2014-12-04 Thread Daniel Lieberman
We have a situation where our app servers sometimes get into a bad state, and 
hitting a working server is more important than enforcing persistence.  
Generally the number of connections to a bad server grows rapidly, so we’ve set 
a maxconn value on the server line which effectively takes a server out of the 
pool when the bad state occurs.

If we fill up the connection slots, the server is almost definitely bad, so 
we’d rather not queue at all.  Since maxqueue 0 means unlimited, it looks like 
the minimum queue size is 1.  Is that right?  Is there any way to enforce a 
redispatch whenever we’re at maxconn, without any connections getting queued?

Thanks,
-Daniel


Can not set or clear a table when the Key contains \

2014-12-04 Thread Nick
Hi Haproxy experts,
we are using Haproxy to balance RDP connections, I am having a problem to 
set or clear a key in a table. below is my skick-table sttings.
stick-table type string len 32 size 10k expire 1d peers LB store 
conn_cur,conn_rate(1m)

70% Haproxy captured the key=userID, this is what i need.
but 30% of the time Haproxy captured the Key=domain\\userID.

I am have requests to set or clear the key in order to assign connection 
to a specific server.
when i try the command --echo -e set table RD01-CSN-1 key PVG\\PENGZ 
data.server_id 3  | socat /var/run/haproxy.stat stdio, the unix socket 
seems excluded the backslash \\, so i cannot successfully edit the 
Haproxy tables.
the same problem when i try the command echo -e clear table RD01-CSN-1 
key PVG\\PENGZ data.server_id 3  | socat /var/run/haproxy.stat stdio.


can someone help ?

thanks in advance.

Nick