1
0
Fork 0
docker-easy-haproxy/tests_e2e/fixtures/header-echo
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
..
Dockerfile Migrate examples to tests_e2e directory structure 2026-02-12 17:05:04 -05:00
README.md Migrate examples to tests_e2e directory structure 2026-02-12 17:05:04 -05:00
server.py 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

Header Echo Server - Test Fixture

A lightweight Python HTTP server that echoes all request headers as JSON. Used for testing HAProxy plugins that manipulate headers and client IPs.

Purpose

This test fixture is used by both Docker Compose and Kubernetes test suites to verify:

  • Header manipulation (e.g., X-Forwarded-For, CF-Connecting-IP)
  • IP restoration plugins (Cloudflare, custom CDN integrations)
  • Request routing and backend visibility

Usage

Docker Compose

services:
  webapp:
    build: ../fixtures/header-echo
    ports:
      - "8080:8080"

Kubernetes

# Build and load into kind cluster
docker build -t header-echo-server:test .
kind load docker-image header-echo-server:test --name your-cluster

# Use in deployment
spec:
  containers:
  - name: webapp
    image: header-echo-server:test
    imagePullPolicy: Never

Manual Testing

# Start the server
python3 server.py

# Test it
curl http://localhost:8080
# Returns JSON with all headers, client IP, and X-Forwarded-For value

Response Format

{
  "headers": {
    "Host": "localhost:8080",
    "User-Agent": "curl/7.81.0",
    "Accept": "*/*"
  },
  "client_ip": "127.0.0.1",
  "x_forwarded_for": "NOT SET"
}

Used By

  • tests_e2e/docker/docker-compose-cloudflare.yml
  • tests_e2e/test_docker_compose.py::TestCloudflare
  • tests_e2e/kubernetes/cloudflare.yml
  • tests_e2e/test_kubernetes.py::TestCloudflare