I want to use HAProxy’s REST API to deploy load-balancer changes to my cluster. I’m following the documentation here:
https://www.haproxy.com/doc/aloha/7.0/api/webbased.html#examples-with-curl
I’ve started up a docker instance using the official alpine build:
docker run -d -v /ops/haproxy:/usr/local/etc/haproxy --name haproxy -p 80:80 -p 4444:4444 haproxy:1.7.2-alpine
The instance comes up and I’ve confirmed that it’s listening on 80 and 4444. According to the documentation the API should be on port 4444:
A minimal curl request would be:
curl -k -u admin:admin https://10.0.0.1:4444/api
However when I try to connect to the API it’s failing:
$curl -k -u admin:admin https://127.0.0.1:4444/api
curl: (35) Unknown SSL protocol error in connection to 127.0.0.1:4444
$curl http://127.0.0.1:4444/api
curl: (56) Recv failure: Connection reset by peer
When I use --net=host instead of manual port binding HAProxy is only binding port 80 - which is defined in my haproxy.cfg.
How do I connect to the API and set authentication to use it, i.e. change admin:admin to something a little harder to guess?