Hi,

You can either use the disable-on-404 health checking option or using
HAProxy socket to disable servers temporarly (I mean temporarly because the
UNIX socket applies changes in running HAProxy process, not in its startup
configuration file).
You could then have a few simple acl matching the number of available
servers in a farm (this also may mean you must have a backend by
application).

use_backend maintenance_page if is_app1 nb_srv(bk_app1) eq 0
use_backend bk_app1                if is_app1

now, just create a bash script to loop through the HAProxy unix stat socket
to disable the servers:
echo "disable server bk_app1/srv1" | socat /var/run/haproxy.socket -

Baptiste




On Tue, Apr 2, 2013 at 8:42 AM, Unai Rodriguez <[email protected]> wrote:

> Dear List,
>
> We have a number of applications behind HAProxy. Sometimes we need to put
> one of the applications in maintenance mode (i.e. display a "This page is
> under maintenance banner"). We achieve that with the following rules:
>
> acl is_app1 hdr(host) app1.example.com
> acl is_app2 hdr(host) app2.example.com
> acl is_app3 hdr(host) app3.example.com
> acl is_app4 hdr(host) app4.example.com
> acl is_app5 hdr(host) app5.example.com
> acl is_app6 hdr(host) app6.example.com
> acl is_app7 hdr(host) app7.example.com
> acl is_app8 hdr(host) app8.example.com
> acl is_app9 hdr(host) app9.example.com
> acl is_app0 hdr(host) app0.example.com
>
> use_backend maintenance_page if is_app1
> #use_backend maintenance_page if is_app2
> #use_backend maintenance_page if is_app3
> #use_backend maintenance_page if is_app4
> #use_backend maintenance_page if is_app5
> #use_backend maintenance_page if is_app6
> #use_backend maintenance_page if is_app7
> #use_backend maintenance_page if is_app8
> #use_backend maintenance_page if is_app9
> #use_backend maintenance_page if is_app0
>
> Currently what we do is comment/uncomment lines manually and reload
> HAProxy when wanting to put app1, app2, app3... under maintenance.
>
> This is somewhat error prone and we are looking for a way of doing this in
> a more sophisticated manner. Ideally someone should be able to login on a
> simple web page, click a button and enable/disable applications as needed.
>
> We used to do that in the past by having several HAProxy configurations
> but now this would mean to have 100 config files to cover all different
> posibilities.
>
> What ACLs can be used so that HAProxy does NOT need to be reloaded? We
> haven't been able to find matching criteria that depends on the existance
> of a file locally for example (or some other environment variable). I guess
> we could serve HTTP 200 or HTTP 503 for example (to put appX on/off) but is
> there a more elegant/better way?
>
> Thank you so much
>
> --
> unai
>
>

Reply via email to