HAProxy is a free, open source high availability solution, providing load balancing and proxying for TCP and HTTP-based applications by spreading requests across multiple servers. It is written in C and has a reputation for being fast and efficient (in terms of processor and memory usage).
See HAProxy.org for more information This image is built by IBM to run on the IBM Z architecture and is not affiliated with any other community that provides a version of this image.3.0.0-bookworm | docker pull icr.io/ibmz/haproxy@sha256:5bb042ac6e1ca1f4f4b71491be7945ca64a20972ecd2db6b7ce59b6289aaa065 | Vulnerability Report | 10-07-2024 |
Version | Pull String | Security (IBM Cloud) | Created |
---|---|---|---|
Since no two users of HAProxy are likely to configure it exactly alike, this image does not come with any default configuration.
Please refer to upstream's excellent (and comprehensive) documentation on the subject of configuring HAProxy for your needs.
It is also worth checking out the examples/ directory from upstream.
At a basic level, an HAProxy confirguration file, called haproxy.cfg, is created to define haproxy's function. Here is a basic example of what haproxy.cfg might look like:
frontend http_front
bind *:80
default_backend http_back
backend http_back
balance roundrobin
server example-server [Page IP]:[Page Port] check
This configuration will cause HAProxy to listen on port number 80, then direct traffic to the server defined in the backend. For an easy demonstration, the server could be set up as any other running Docker container
on your system which serves a webpage. In that case, you would set [Page IP]
to your system's IP, and [Page Port]
to the port you assigned the container to listen on.
Dockerfile
in the directory containing your haproxy.cfg
file:
FROM icr.io/ibmz/haproxy:[version]
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
docker build -t my-haproxy .
docker run -it --rm --name haproxy-syntax-check my-haproxy haproxy -c -f /usr/local/etc/haproxy/haproxy.cfg
This should return the text Configuration file is valid
.
docker run -d -p 8098:80 --name run-haproxy --sysctl net.ipv4.ip_unprivileged_port_start=0 my-haproxy
You can now access [Your system IP]:8098 in a browser window. This should direct you to the destination specified in HAProxy.cfg!