Dawid Sieradzki / Gadu-Gadu S.A. pisze:
Hi.

The problem is how to silent switch to another backend in realtime if got 500 answer from backend, without http_client knowledge Yes i know, httpchk, but the error 500 is 10 per hour, we don't know when and why.
So, it is a race who get 500 first - httpchk or http_client.

If You don't know what i mean:

example config:

----8<--------

frontend
(..)
default_backend back_1

backend back_1
   option httpchk GET /index.php HTTP/1.1\r\nHost:\ test.pl
   mode http
   retries 10
   balance roundrobin

 server chk1 127.0.0.1:81 weight 1 check
 server chk2 127.0.0.1:82 weight 1 check
 server chk3 127.0.0.1:83 weight 1 check backup

---->8----------

http_client -> haproxy -> (backend1|backend2|backend3)

let's go inside request:

A. haproxy recived request from http_client
B. haproxy sent request from http_client to backend1
C. backend1 said 500 internal server error

I want: :-)
D. haproxy sent request from_http to backend2 (or backup backend or another one, or one more time to backend1)

I have: :-(
D. haproxy sent 500 internal server error to http_client from backend1
E. haproxy will mark backend1 as down if got 2 > errror 500 from backend1


It is possible to do that?


Hello,

Yes it is possible but it could be dengerous for some kinde of application fe. billing system ;) Here is an example how to do it. I know that it is the hack but it works good ;P

frontend fr1
      default_backend back_1
rspirep ^HTTP/...\ [23]0..* \0\nSet-Cookie:\ cookiexxx=0;path=/;domain=.yourdomain.com rspirep ^(HTTP/...)\ 5[0-9][0-9].* \1\ 202\ Again\ Please\nSet-Cookie:\ cookiexxx=1;path=/;domain=.yourdomain.com\nRefresh:\ 6\nContent-Length:\ Lenght_xxx\nContent-Type:\ text/html\n\n<FRAMESET\ cols="100%"><FRAME\ src="http://www.yourdomain.com/redispatch.pl";>

backend back_1
       cookie          cookiexxx
       server chk1 127.0.0.1:81 weight 1 check
       server chk2 127.0.0.1:82 weight 1 check
       server chk3 127.0.0.1:83 weight 1 check cookie 1 backup

Remember to set Lenght_xxx properly.

Best Regards
Maciej Bogucki

Reply via email to