Skip to content
🚀 Limited-time offer $130 for Lifetime Pro access. Buy once and use forever

Status List

Uptime & Status Pages

HAProxy + Docker Setup Guide

HAProxy is really easy to run in docker. Let’s start by pulling the official docker image: docker pull haproxy.

docker hub

Setup Dockerfile

Create a dockerfile in your working directory. Our dockerfile is going to be very simple. Pull HAProxy and copy in our configuration file. Here’s an example:

					FROM haproxy:latest # you can also pin a specific version here
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg

That’s all there is to it. Very simple and straightforward.

Ready to know about downtime before your customers?
Status List delivers uptime monitoring and professional hosted status pages for sites of all shapes and sizes.

Trusted by 1000+ companies

Setup HAProxy Config

Next, create an haproxy.cfg file. Below is a sample you can start from. You can see our HAProxy configuration guide for more specific use-cases and setup instructions.

    log /log local0
    maxconn 4000
    mode http
    log global
    timeout client 30s
    timeout connect 10s
    timeout server 240s
frontend ft_web
    bind *:80
    mode http
    default_backend bk_web
backend bk_web
    balance leastconn
    server web_1 check
    server web_2 check

Running HAProxy in Docker

Next, build and run your container:

					docker build -t lb-haproxy .
docker run -d --name haproxy --sysctl net.ipv4.ip_unprivileged_port_start=0 -p 80:80 lb-haproxy

You can now send requests to port 80 on the host machine and they will be routed by HAProxy to your 2 backends.