Public | Automated Build

Last pushed: 2 years ago
Short Description
Haproxy based on official image. Load balancer configuration thru environment variables.
Full Description

Create static python http server on new docker machine called http1:

docker-machine create --driver virtualbox http1
eval $(docker-machine env http1)
docker run -d -p 8080:8080 python python -m http.server 8080
curl `docker-machine ip http1`:8080

Repeat the steps once more to have at least two http servers

docker-machine create --driver virtualbox http2
eval $(docker-machine env http2)
docker run -d -p 8080:8080 python python -m http.server 8080
curl `docker-machine ip http2`:8080

Create machine for haproxy and run docker image which automatically maps environment variables to haproxy configuration. The only required environment varialbe is SERVERS. This image use creates sticky cookie. Use this image for test purposes. Https not supported.

docker-machine create --driver virtualbox loadbalancer
eval $(docker-machine env loadbalancer)
docker run -d -p 8080:80 -e SERVERS="`docker-machine ip http1`:8080;`docker-machine ip http2`:8080" vaclavnemec/haproxy:latest
curl `docker-machine ip loadbalancer`:8080

Environment variables you can specify. Please refer to official haproxy documentation

  • SERVERS - list of servers in the format "host1:port1;host2:port2"
  • MAX_CONNECTION - number of connections
  • TIMEOUT_CONNECTION - timeout for connection
  • TIMEOUT_CLIENT
  • TIMEOUT_SERVER
  • COOKIE - cookie name for sticky session
  • SERVER_MAX_CONNECTION
Docker Pull Command
Owner
vaclavnemec
Source Repository

Comments (0)