In that case I'm not sure how to make it work. Seems like you will need to modify http_proto.c to cause the request to attempt to be redispatched when haproxy receives a valid 502 http response from the server. I doubt that this is the only thing to change, but it probably involves changing this section of code and others:
if (unlikely(msg->msg_state < HTTP_MSG_BODY)) { /* Invalid response */ if (unlikely(msg->msg_state == HTTP_MSG_ERROR)) { /* we detected a parsing error. We want to archive this response * in the dedicated proxy area for later troubleshooting. */ hdr_response_bad: if (msg->msg_state == HTTP_MSG_ERROR || msg->err_pos >= 0) http_capture_bad_message(&s->be->invalid_rep, s, rep, msg, s->fe); s->be->counters.failed_resp++; if (s->srv) { s->srv->counters.failed_resp++; health_adjust(s->srv, HANA_STATUS_HTTP_HDRRSP); } abort_response: buffer_auto_close(rep); rep->analysers = 0; txn->status = 502; rep->prod->flags |= SI_FL_NOLINGER; buffer_ignore(rep, rep->l - rep->send_max); stream_int_retnclose(rep->cons, error_message(s, HTTP_ERR_502)); if (!(s->flags & SN_ERR_MASK)) s->flags |= SN_ERR_PRXCOND; if (!(s->flags & SN_FINST_MASK)) s->flags |= SN_FINST_H; return 0; } The server level redispatch function appears to really be designed for backend server connect failures so this is most likely a bad idea. -Jerry Jerry Champlin Absolute Performance Inc. -- Enabling businesses to deliver critical applications at lower cost and higher value to their customers. On Mon, Aug 23, 2010 at 5:15 PM, Dustin Moskovitz <mos...@asana.com> wrote: > If I understand correctly, that sends a redirect request back to the > client? We need this for RPCs, so that won't really work. > > > On Mon, Aug 23, 2010 at 3:50 PM, Jerry Champlin < > j...@absolute-performance.com> wrote: > >> Dustin: >> >> It's a little more elaborate and potentially dangerous than I was >> thinking, but this link illustrates a way to do what I think you are after. >> http://www.formilux.org/archives/haproxy/0906/2144.html >> >> The solution from Maciej Bogucki is pasted below for ease: >> >> 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 >> >> -Jerry >> >> Jerry Champlin >> Absolute Performance Inc. >> -- >> Enabling businesses to deliver critical applications at lower cost and >> higher value to their customers. >> >> >> On Mon, Aug 23, 2010 at 2:13 PM, Dustin Moskovitz <mos...@asana.com>wrote: >> >>> Hey Jerry, can you elaborate? >>> >>> To be clear what happens is: >>> 1/ proxy receives requests >>> 2/ proxy sends request to webserver >>> 3/ webserver sends 502 response to proxy >>> 4/ proxy forwards 502 response to the end user >>> >>> I do have other webservers that I want to re-dispatch the request to - is >>> that what you mean by backup servers? In any case, it seems like the proxy >>> must be the one responsible for handling the failure. >>> >>> >>> On Fri, Aug 20, 2010 at 12:08 PM, Jerry Champlin < >>> j...@absolute-performance.com> wrote: >>> >>>> It seems like you could configure backup servers within the pool to >>>> accomplish this although it's not quite as clean as what I suspect you are >>>> looking for. >>>> >>>> -Jerry >>>> >>>> Jerry Champlin >>>> Absolute Performance Inc. >>>> -- >>>> Enabling businesses to deliver critical applications at lower cost and >>>> higher value to their customers. >>>> >>>> >>>> >>>> On Fri, Aug 20, 2010 at 12:54 PM, Dustin Moskovitz <mos...@asana.com>wrote: >>>> >>>>> Hi all, >>>>> We run haproxy in front of a bank of nginx servers, which each proxy >>>>> requests to a custom web server on the same box. >>>>> >>>>> I was wondering if it is possible to configure haproxy such that it >>>>> will redispatch requests that receive a 502 from nginx to a new server. I >>>>> looked through the docs but could not find anything that seemed relevant. >>>>> >>>>> Dustin >>>>> >>>> >>>> >>> >> >