HAProxy label based routing with service discovery for Docker, Swarm, and Kubernetes
Project description
EasyHAProxy
Service discovery for HAProxy
EasyHAProxy dynamically creates the haproxy.cfg based on metadata collected from your workloads (Docker labels, Swarm service labels, or Kubernetes ingress annotations).
EasyHAProxy can detect and configure HAProxy automatically on the following platforms:
- Docker
- Docker Swarm
- Kubernetes
- Static YAML definitions (
EASYHAPROXY_DISCOVER=static)
Who is using?
EasyHAProxy is part of some projects:
- Dokku
- MicroK8s
- DigitalOcean Marketplace
See detailed instructions on how to install below.
EasyHAProxy Mission
Easy to set up and low configuration to numerous features.
Features
EasyHAProxy will discover services based on Docker (or Swarm) labels and Kubernetes ingress annotations, then dynamically build the haproxy.cfg. Below, EasyHAProxy main features:
- Support Automatic Certificate Management Environment (ACME) protocol compatible with Let's Encrypt and other CAs.
- Set your custom SSL certificates
- Balance traffic between multiple replicas
- Set SSL policies (
strict,default,loose) viaEASYHAPROXY_SSL_MODE. - Set up HAProxy to listen to TCP.
- Add redirects.
- Enable/disable Stats on port 1936 with a custom password.
- Enable/disable custom errors.
Also, it is possible to set up HAProxy from a simple Yaml file instead of creating haproxy.cfg file.
How Does It Work?
You don't need to change your current infrastructure and don't need to learn the HAProxy configuration.
The steps are:
- Run the EasyHAProxy container;
- Add some labels to the containers you want to be parsed by EasyHAProxy (see detailed instructions below);
- EasyHAProxy will automatically detect the containers, set up, and reload the HAProxy configurations for you without downtime.
Detailed Instructions
For detailed instructions on how to use EasyHAProxy, follow the instructions for the platform you want to use:
Or you can install using tools:
Special Topics
If you already set up the EasyHAProxy, is time to go deeper:
- Custom SSL
- Automatic Certificate Issuing (e.g. Letsencrypt)
Configuration Reference
Detailed configuration guides for advanced setups:
- Container Labels - Configure Docker/Swarm containers with labels
- Environment Variables - Configure EasyHAProxy behavior
- Volumes - Map volumes for certificates, config, and custom files
- Plugins - Extend HAProxy with plugins (Development Guide)
- JWT Validator - JWT authentication validation
- FastCGI - PHP-FPM and FastCGI application support
- Cloudflare - Restore visitor IP from Cloudflare CDN
- IP Whitelist - Restrict access to IPs/CIDR ranges
- Deny Pages - Block access to specific paths
- Cleanup - Automatic cleanup of temporary files
- Other Configurations - Additional configurations (ports, custom errors, etc.)
- Limitations - Important limitations and considerations
Development
Requirements
- Python 3.11 or higher
- uv package manager
Installation for Development
# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone the repository
git clone https://github.com/byjg/docker-easy-haproxy.git
cd docker-easy-haproxy
# Install dependencies (creates virtual environment automatically)
uv sync --dev
# Run tests
make test
# or directly: uv run pytest tests/ -vv
# Run linting
make lint
# Format code
make format
Installing the Package
# Install with uv
uv pip install easymapping
# Or install from source
uv pip install -e ".[dev]"
See EasyHAProxy in action
Click on the image to see the videos (use HD for better visualization)
Here is the code applied in the test examples above.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file easyhaproxy-6.0.0.tar.gz.
File metadata
- Download URL: easyhaproxy-6.0.0.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23e80e54a78d128a8d91c4405d663764c05ffa088a5a9c57c96227c4f0617daa
|
|
| MD5 |
15f47193afca8aafbded031723ad79e8
|
|
| BLAKE2b-256 |
0a380e112f1fbeac01222c74273ca76ad89d240ae294a212b101ac01f20799ba
|
Provenance
The following attestation bundles were made for easyhaproxy-6.0.0.tar.gz:
Publisher:
build.yml on byjg/docker-easy-haproxy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
easyhaproxy-6.0.0.tar.gz -
Subject digest:
23e80e54a78d128a8d91c4405d663764c05ffa088a5a9c57c96227c4f0617daa - Sigstore transparency entry: 964199618
- Sigstore integration time:
-
Permalink:
byjg/docker-easy-haproxy@3b8818e6369105f425b1fa4b0a379cb806a422df -
Branch / Tag:
refs/tags/6.0.0 - Owner: https://github.com/byjg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@3b8818e6369105f425b1fa4b0a379cb806a422df -
Trigger Event:
push
-
Statement type:
File details
Details for the file easyhaproxy-6.0.0-py3-none-any.whl.
File metadata
- Download URL: easyhaproxy-6.0.0-py3-none-any.whl
- Upload date:
- Size: 53.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f1a7bcb92ebb67d27ed42f73c63db3f196513577f527c0dccf43fe276c587c8
|
|
| MD5 |
6216a46b5c8155d2305360ae0cb65863
|
|
| BLAKE2b-256 |
12067f8f1ef0120a5160e68ff309bdb377fdb160bd53ff5930d2afac959aef83
|
Provenance
The following attestation bundles were made for easyhaproxy-6.0.0-py3-none-any.whl:
Publisher:
build.yml on byjg/docker-easy-haproxy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
easyhaproxy-6.0.0-py3-none-any.whl -
Subject digest:
9f1a7bcb92ebb67d27ed42f73c63db3f196513577f527c0dccf43fe276c587c8 - Sigstore transparency entry: 964199712
- Sigstore integration time:
-
Permalink:
byjg/docker-easy-haproxy@3b8818e6369105f425b1fa4b0a379cb806a422df -
Branch / Tag:
refs/tags/6.0.0 - Owner: https://github.com/byjg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@3b8818e6369105f425b1fa4b0a379cb806a422df -
Trigger Event:
push
-
Statement type: