Skip to content

brzlvch/haproxy-switcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

HAProxy backend server switcher

This script uses HAProxy stats (via socket) to enable/disable the backend server

Docs — https://docs.haproxy.org/2.4/management.html#9.3

Preliminary setup

To begin with, install socat on Linux machine as seen below

sudo apt install socat

Next, open the HAProxy configuration file and add the following lines in the global section to enable the stats socket:

global
    stats socket /var/run/haproxy.sock mode 600 level admin
    stats timeout 2m

Then, save the configuration file and restart the HAProxy service

sudo systemctl restart haproxy.service

Options

The order of arguments is NOT important

  • -enable - Enable the backend server
  • -disable - Enable the backend server
  • -socket - Path to socket file of HAProxy stats
  • "backend/server" - Path of "backend/server" for action

Using

bash haproxy-switcher.sh

OR

bash haproxy-switcher.sh "web443/server-1" -socket "/var/run/haproxy_db.sock" -disable

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages