From e7ca5f53b2f8924ef5000a15a167181eb8eaecfb Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 15 Jan 2023 14:07:16 +0100 Subject: [PATCH] feat: Added a first working simple configuration for HAProxy --- README.sh | 2 ++ docker-compose.yml | 16 ++++++++++++++++ haproxy.cfg | 23 +++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 README.sh create mode 100644 haproxy.cfg diff --git a/README.sh b/README.sh new file mode 100644 index 00000000..7b489490 --- /dev/null +++ b/README.sh @@ -0,0 +1,2 @@ +#!/bin/sh +docker run --rm --sysctl net.ipv4.ip_unprivileged_port_start=0 -v $(pwd)./haproxy.cfg://usr/local/etc/haproxy/haproxy.cfg:ro haproxy:2.7 -c diff --git a/docker-compose.yml b/docker-compose.yml index 9f476d03..6d093704 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -84,6 +84,22 @@ services: depends_on: - kafka-0 + haproxy: + image: haproxy:2.7 + volumes: + - ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro + sysctls: + net.ipv4.ip_unprivileged_port_start: 0 + ports: + - 8080:80 + - 8404:8404 + + web1: + image: nginx:1.17 + web2: + image: nginx:1.17 + web3: + image: nginx:1.17 setup: image: juplo/toolbox diff --git a/haproxy.cfg b/haproxy.cfg new file mode 100644 index 00000000..f334457c --- /dev/null +++ b/haproxy.cfg @@ -0,0 +1,23 @@ +# Config from Blog-article "How to Run HAProxy with Docker" +defaults + mode http + timeout client 10s + timeout connect 5s + timeout server 10s + timeout http-request 10s + log global + +frontend stats + bind *:8404 + stats enable + stats uri / + stats refresh 10s + +frontend frontend + bind :80 + default_backend webservers + +backend webservers + server s1 web1:80 check + server s2 web2:80 check + server s3 web3:80 check -- 2.20.1