Skip to content

Instantly share code, notes, and snippets.

@haproxytechblog
Created August 4, 2021 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haproxytechblog/5c9f3df627345690188a62e46fc7cfeb to your computer and use it in GitHub Desktop.
Save haproxytechblog/5c9f3df627345690188a62e46fc7cfeb to your computer and use it in GitHub Desktop.
The HAProxy APIs
global
stats socket /var/run/haproxy/api.sock user haproxy group haproxy mode 660 level admin expose-fd listeners
global
stats socket ipv4@127.0.0.1:9999 level admin expose-fd listeners
$ echo "help" | sudo socat stdio /var/run/haproxy/api.sock
$ echo "help" | socat stdio tcp4-connect:127.0.0.1:9999
$ echo "set server webservers/server1 state drain" |\
sudo socat stdio /var/run/haproxy/api.sock
$ sudo dataplaneapi -f /etc/haproxy/dataplaneapi.hcl
$ curl -X GET --user admin:adminpwd http://localhost:5555/v2/info
{"api":{"build_date":"0001-01-01T00:00:00.000Z","version":"v2.2.0 68bd22b"},"system":{}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment