1
0
Fork 0
docker-easy-haproxy/tests_e2e/docker/docker-compose-multi-containers.yml
Joao Gilberto Magalhaes d66c4f8595 Migrate examples to tests_e2e directory structure
- Relocated all files and scripts from `examples` to `tests_e2e` for better organization.
- Updated references and paths in configurations, scripts, and test files.
- Adjusted `bump-version.sh` to handle the new `tests_e2e` structure.
- Updated `.gitignore` to reflect path changes.
2026-02-12 17:05:04 -05:00

76 lines
2.1 KiB
YAML

# ==============================================================================
# EXAMPLE: Load Balancing with Multiple Container Replicas
# ==============================================================================
#
# WHAT THIS DEMONSTRATES:
# - Multiple container replicas behind a single domain
# - Round-robin load balancing across replicas
# - Domain redirect functionality
# - Custom port configuration
#
# REQUIREMENTS (run these first):
# ```bash
# # No special requirements - this example runs on localhost:19901
# ```
#
# HOW TO START:
# ```bash
# docker compose -f docker-compose-multi-containers.yml up -d
# ```
#
# HOW TO VERIFY IT'S WORKING:
# ```bash
# # Test load balancing - hostname should alternate between containers
# curl -H "Host: www.helloworld.com" localhost:19901
# # Expected: Container ID (e.g., f6d8d45b7411)
# curl -H "Host: www.helloworld.com" localhost:19901
# # Expected: Different container ID (e.g., 59b213cb8592)
#
# # Test domain redirect
# curl -I -H "Host: google.helloworld.com" localhost:19901
# # Expected: HTTP/1.1 301 Moved Permanently, Location: www.google.com/
#
# # View HAProxy stats
# # URL: http://localhost:1936
# # Username: admin
# # Password: password
# # You should see 2 backend servers
# ```
#
# CLEAN UP:
# ```bash
# docker compose -f docker-compose-multi-containers.yml down
# ```
#
# ==============================================================================
services:
haproxy:
build:
context: ../../
dockerfile: build/Dockerfile
image: byjg/easy-haproxy:local
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
EASYHAPROXY_DISCOVER: docker
HAPROXY_CUSTOMERRORS: "true"
HAPROXY_USERNAME: admin
HAPROXY_PASSWORD: password
HAPROXY_STATS_PORT: 1936
ports:
- 19901:19901
- 1936:1936
nginx:
#image: nginx
image: stenote/nginx-hostname
deploy:
replicas: 2
labels:
easyhaproxy.http.redirect: '{"google.helloworld.com": "www.google.com"}'
easyhaproxy.http.host: www.helloworld.com
easyhaproxy.http.port: 19901
easyhaproxy.http.localport: 80