We've tended to disable backend servers for specific backends as part of our 
deployer integration, so it makes a certain amount of sense for us to use the 
same basic methodology to push something into a particular backend. (We also 
don't have to restart haproxy to adjust the configuration, since the 
admin/stats socket allows dynamic "MAINT" mode.)

In case it's useful for anyone, the CLI setup for dealing with this in batch 
(nbproc > 1 with an N+1 cluster of haproxy servers) is here:

https://github.com/jbuchbinder/hactl

I have similar logic built into our software deployer to handle it 
transparently. (I'm not sure if the "backup" attribute for backend servers is 
*supposed* to be used the way we've been using it, but it does a great job of 
routing traffic elsewhere when all servers are either down or in MAINT.)

Thanks,
Jeff

________________________________________
From: Philipp Buehler <[email protected]>
Sent: Sunday, January 24, 2016 12:20 PM
To: Jeff Buchbinder
Cc: Haproxy
Subject: Re: Temporary Maintenance frontend for all port 80/443 ?

Am 24.01.2016 17:58 schrieb Jeff Buchbinder:
> The way we've done it has been to add a maintenance server to all of
> our backends, then use the admin socket to iteratively disable all
> "real" servers for our backends. The maintenance server points all
> requests to your temporary page.
>
> Something like:
>
>  server  maintenance 10.0.5.10:80 backup check inter 15000 rise 2 fall
> 5

We're doing yet another approach, which is easier to "steer".
Watch closely about the logic ..

frontend whatever
  acl usrnb nbsrv(usr) gt 0
  acl usr_h_nb nbsrv(usr_h) eq 0
  use_backend usr if usrnb usr_h_nb
  use_backend usr_h

backend usr
  server usr usr021:8080 check downinter 30000 fastinter 3000 fall 2

backend usr_h
  server helper localhost:8000 check downinter 30000 fastinter 3000 fall
2
  option httpchk GET /maint.txt HTTP/1.1\r\nHost:\ hidden

- NO need to fiddle with haproxy.conf and/or restarts of haproxy itself
- regular ops: usrnb is true, usr_h_nb is false (no maint.txt/nginx)
- irr ops: usrnb is false -> use usr_h (which has its own logic for
serving sorry pages)
- maint: "touch maint.txt" -> usr_h_nb is false -> use usr_h (value of
usrnb irrelevant)

FTR; nginx.conf snippet:
     server {
         listen 8000;
         server_name hidden;
         access_log /var/log/nginx/maint.log main;
         location /maint.txt { access_log off; }
         location / {
             sorry-pages-things;
         }
     }

HTH,
--
pb

Reply via email to