feat: Added a first working simple configuration for HAProxy
authorKai Moritz <kai@juplo.de>
Sun, 15 Jan 2023 13:07:16 +0000 (14:07 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 15 Jan 2023 15:36:46 +0000 (16:36 +0100)
README.sh [new file with mode: 0644]
docker-compose.yml
haproxy.cfg [new file with mode: 0644]

diff --git a/README.sh b/README.sh
new file mode 100644 (file)
index 0000000..7b48949
--- /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
index 9f476d0..6d09370 100644 (file)
@@ -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 (file)
index 0000000..f334457
--- /dev/null
@@ -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