This project demonstrates how to use the events framework in an HAProxy Lua module.
To use it with Docker Compose:
-
Install Docker Desktop.
-
Go to
https://webhook.site/
to get a uniquewebhook.site
URL. -
Edit the file
docker-compose.yml
and change theDEMO_WEBHOOK_URL
variable to be yourwebhook.site
URL. -
Call the
docker compose up
command to create the container environment:$ docker compose up
-
On your host machine, install
socat
(or use another tool like Netcat) to send commands to the HAProxy Runtime API, which listens at port 9999.Below, we disable the two web servers, which triggers the
SERVER_DOWN
event in Lua, sending a web request to yourwebhook.site
URL.$ echo "set server test/webserver1 health down" | socat stdio tcp4-connect:127.0.0.1:9999 $ echo "set server test/webserver2 state maint" | socat stdio tcp4-connect:127.0.0.1:9999
-
Check
webhook.site
to see the request displayed. -
Stop and clean up the containerized environment with
docker compose down
:$ docker compose down