Hi,

Thank you for your answer. I changed my configuration like this :

  tcp-check send GET\ /mycheck\ HTTP/1.1\r\nHost:\ myhost\r\nConnection:\
close\r\n
  tcp-check send \r\n
  tcp-check expect string HTTP/1.1\ 200\ OK
  tcp-check expect ! string "healthStatus":"Unhealthy"

And it works very well. Even in SSL. You now have my eternal gratitude :)

Sébastien Rohaut

2015-02-16 22:22 GMT+01:00 Baptiste <[email protected]>:

> On Mon, Feb 16, 2015 at 9:29 PM, Sébastien ROHAUT
> <[email protected]> wrote:
> > Hi,
> >
> > I'm using an http-check expect string to test the presence of a certain
> > string in the body response. Like this
> >
> > option httpchk GET /mycheck HTTP/1.1\r\nHost:\ myhost.xx\r\nConnection:\
> > close
> > http-check expect ! string "healthStatus":"Unhealthy"
> >
> > When the backend is not accessible, our nginx returns a default page,
> with a
> > 5XX return code.
> >
> > In this case (return code != 200), it should be considered as an error,
> and
> > the associated serveur should be removed from the server. It's not the
> case
> > : HAProxy only check the string, and says it's OK.
> >
> > Question :
> >
> > How to check the string AND check the return code ? I want my server to
> be
> > removed if string is absent OR if return code is != 200 !
> >
> > Thank you,
> >
> > Sébastien Rohaut
>
> Hi Sébastien,
>
> You can write such séquence using tcp-check, sending your HTTP request
> with tcp-check send and matching with two consecutive tcp-check expect
> rules:
> tcp-check expect string HTTP/1.1\ 200\ OK
> tcp-check expect ! string "healthStatus":"Unhealthy"
>
> Baptiste
>

Reply via email to