1. Images & Charts
  2. haproxy
haproxy

haproxy

Infra
Updated yesterday

HAProxy Overview

Secure your stack with a hardened HAProxy image freshly-built by Minimus. Minimus images always include the most up-to-date package version for all packages and dependencies contained in the image.


HAProxy (High Availability Proxy) is an open source TCP/HTTP load balancer and reverse proxy used to optimize performance and reliability for server environments at scale.


Try It Out

To take the Minimus HAProxy image for a test run, we will run 2 simple Python HTTP servers and use HAProxy to alternate between them.

Run the first Python HTTP server:

(
python3 - <<EOF
from http.server import BaseHTTPRequestHandler, HTTPServer

class Handler(BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.end_headers()
        self.wfile.write(b'Hello from Web Server 1!')

HTTPServer(('', 8081), Handler).serve_forever()
EOF
) &

Next, run the second Python HTTP server:

(
python3 - <<EOF
from http.server import BaseHTTPRequestHandler, HTTPServer

class Handler(BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.end_headers()
        self.wfile.write(b'Greetings from Web Server 2!')

HTTPServer(('', 8082), Handler).serve_forever()
EOF
) &

Save the configuration below to a new file in your project directory and name it haproxy.cfg. This configuration alternates between the two HTTP servers:

global
    log stdout format raw daemon

defaults
    log global
    timeout connect 5s
    timeout client  30s
    timeout server  30s

frontend http_front
    bind *:80
    default_backend http_back

backend http_back
    balance roundrobin
    server web1 172.17.0.1:8081 check
    server web2 172.17.0.1:8082 check

Note that this setup assumes you're using Docker's default bridge network on Linux. If you're using Mac, Windows, or a custom setup, replace 172.17.0.1 with your host IP.

Finally, run the Minimus HAProxy container from the directory in which the haproxy.cfg is located:

docker run -d \
    --name minimus-haproxy \
    -p 80:80 \
    -v ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg \
    reg.mini.dev/haproxy \
    haproxy -db -f /usr/local/etc/haproxy/haproxy.cfg

Now that our testing environment is set up, run the following multiple times:

curl http://localhost

You should see the output alternate between these messages: Hello from Web Server 1! and Greetings from Web Server 2!

Deploying with Helm charts

When deploying the image with a Helm chart, modify the securityContexts to give it the required privileges. For example, modify the values.yaml as follows so the Pod can bind the net port it works with:

# values.yaml
haproxy:
  enabled: true
  containerSecurityContext:
    capabilities:
      add:
        - NET_BIND_SERVICE

Technical Considerations

The HAProxy image provided by Minimus is a slim, security-hardened alternative to the public image from Docker Hub. The images are largely interchangeable, with a few differences as noted below.

HAProxy built by Minimus:

  1. The entrypoint script is located at /usr/local/bin/docker-entrypoint.sh. The public image entrypoint script is directly under the root directory.
  2. The image has no default working directory, compared with the public image which defaults to the working directory /var/lib/haproxy.
  3. Drill down on the version specification tab to see the default user, listening ports, entrypoint, volumes, environment variables, etc.

The Payoff

A hardened, minimal image that will remain more secure for the long run and accrue vulnerabilities at a slower rate.


Terms & Info

Trademark

This catalog is published by Minimus. All product names, logos, and marks, other than those belonging to Minimus, shown are owned by their respective rights holders and appear here only to identify the open source software each image contains. Minimus claims no ownership of those marks and implies no affiliation with, endorsement by, certification by, or sponsorship by any rights holder.

Disclaimer

Images are provided "as-is" without warranty of any kind. "Hardened" refers to the security configuration applied at the time of build and does not constitute a guarantee of ongoing security or absence of vulnerabilities. The free tier is provided without support, SLA, or guaranteed patching timelines. Security updates may be applied to paid subscriptions before or instead of free tier images. By pulling or using any image you agree to our Terms of Use.