# Start 5 web servers with 2 proxy servers
docker-compose up -d --scale web=5 --scale proxy=2
# show logs of the proxy container
docker-compose logs -f proxy# Access the virtual IP specified in docker-compose.yml
curl -v 172.18.0.101
# Access Statistics Report
curl -v 172.18.0.101:8080# Stop the proxy container in MASTER state
docker stop docker-haproxy_proxy_1
curl -v 172.18.0.101
# Then start it again
# The priority in keepalived.conf is a random integer so that
# the container might enter MASTER or BACKUP state which depends
# on the priority is higher or lower than the priority in another
# proxy container
docker start docker-haproxy_proxy_1
curl -v 172.18.0.101$ cat /etc/redhat-release
CentOS Linux release 7.6.1810
$ docker --version
Docker version 1.13.1, build 7f2769b/1.13.1
$ docker-compose --version
docker-compose version 1.24.1, build 4667896b
$ docker images --format "{{.Repository}}:{{.Tag}}"
docker.io/nginx:1.17.3-alpine
docker.io/haproxy:2.0.7-alpine-
rsyslogd
- install -
apk add rsyslog - config -
rsyslog.conf - define
local0which we will refer in the haproxy.cfg to haproxy.log - link haproxy.log to
stdout
- install -
-
HAProxy
- log to
local0(i.e., stdout) - use
docker dns resolver - response header
X-Serverto indicate which server was chosen - use
server-templateto initialize multiple servers - if haproxy stats
access permission denied
- log to
-
Keepalived
- install -
apk add keepalived - config -
keepalived.conf - automatically determine master/backup by
random priority - automatically figure out
multicast source ip - use official
entrypoint script - according
arc-ts' prerequisites- should do
sysctl net.ipv4.ip_nonlocal_bind=1, but seems not necessary to me - host networking parameter
--net=hostcan beconfigured in docker-compose.yml
- should do
- install -