1
0
Fork 0
No description
Find a file
Joao Gilberto Magalhaes 776f216a36 Add support for proxy-awareness headers: X-Forwarded-For, X-Forwarded-Port, X-Forwarded-Proto, X-Forwarded-Host, and X-Request-ID
- Updated HAProxy configuration template to set all standard proxy headers for HTTP requests.
- Added support for a unique request ID via `unique-id-format` and `unique-id-header` directives.
- Implemented E2E tests for header validation, request correlation, and configuration correctness.
- Enhanced documentation to explain usage and examples of proxy headers.
- Updated CI workflows to include E2E tests for proxy headers.
2026-02-16 17:26:59 -05:00
.github Add support for proxy-awareness headers: X-Forwarded-For, X-Forwarded-Port, X-Forwarded-Proto, X-Forwarded-Host, and X-Request-ID 2026-02-16 17:26:59 -05:00
.run Migrate configuration paths to /etc/easyhaproxy and improve health check support in E2E tests 2026-02-15 14:32:16 -05:00
.vscode Fix errors in the test 2023-02-08 19:27:50 -06:00
build Migrate configuration paths to /etc/easyhaproxy and improve health check support in E2E tests 2026-02-15 14:32:16 -05:00
deploy Improve SSL and ACME documentation 2026-02-16 15:54:32 -05:00
docs Add support for proxy-awareness headers: X-Forwarded-For, X-Forwarded-Port, X-Forwarded-Proto, X-Forwarded-Host, and X-Request-ID 2026-02-16 17:26:59 -05:00
helm/easyhaproxy Add ingress status update functionality to support various deployment modes 2025-12-15 21:11:02 -05:00
scripts Migrate examples to tests_e2e directory structure 2026-02-12 17:05:04 -05:00
src Add support for proxy-awareness headers: X-Forwarded-For, X-Forwarded-Port, X-Forwarded-Proto, X-Forwarded-Host, and X-Request-ID 2026-02-16 17:26:59 -05:00
tests Add support for proxy-awareness headers: X-Forwarded-For, X-Forwarded-Port, X-Forwarded-Proto, X-Forwarded-Host, and X-Request-ID 2026-02-16 17:26:59 -05:00
tests_e2e Add support for proxy-awareness headers: X-Forwarded-For, X-Forwarded-Port, X-Forwarded-Proto, X-Forwarded-Host, and X-Request-ID 2026-02-16 17:26:59 -05:00
.dockerignore Minor changes in github actions 2022-08-26 16:05:18 -05:00
.gitignore Refactor ACME E2E tests: add Pebble health check container, simplify startup logic, and replace Python-based health check 2026-02-16 14:48:39 -05:00
.python-version Modernizing PyThon Projec 2026-01-22 20:14:22 -05:00
build-multiarch.sh Code reorganization 2022-08-26 15:56:13 -05:00
CONTRIBUTING.md Update CONTRIBUTING.md 2024-06-04 21:31:19 -05:00
LICENSE Initial Commit 2018-09-16 21:03:17 -05:00
Makefile Refactor: modernize codebase by replacing deprecated patterns, simplifying imports, and applying type hinting refinements. 2026-01-22 21:47:33 -05:00
pyproject.toml Migrate configuration paths to /etc/easyhaproxy and improve health check support in E2E tests 2026-02-15 14:32:16 -05:00
README.md Migrate examples to tests_e2e directory structure 2026-02-12 17:05:04 -05:00
RELEASE.md Add --current flag to bump-version.sh for displaying current versions 2026-02-07 22:02:53 -05:00
uv.lock Refactor Docker Compose examples and plugins, add pytest tests 2026-02-11 19:19:08 -05:00

EasyHAProxy

Sponsor Opensource ByJG Build Status GitHub source GitHub license GitHub release Helm Version Artifact Hub

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) via EASYHAPROXY_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:

Kubernetes Docker Swarm Docker Static

Or you can install using tools:

Helm MicroK8s Dokku DigitalOcean

Special Topics

If you already set up the EasyHAProxy, is time to go deeper:

Configuration Reference

Detailed configuration guides for advanced setups:

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)

Docker In Action Docker and Letsencrypt K8s In Action K8s and Letsencrypt Static Configuration TCP Mode

Here is the code applied in the test examples above.


Open source ByJG