From f2b383ee19b74b360a5c27ceb1ff3c23ad19f182 Mon Sep 17 00:00:00 2001 From: janic Date: Thu, 28 Jul 2022 22:02:37 +0200 Subject: [PATCH] haproxy --- haproxy/HAPROXY.md | 5 +++++ haproxy/config/haproxy.cfg | 26 ++++++++++++++++++++++++++ haproxy/haproxy-compose.yaml | 8 ++++++++ haproxy/reconfigure-haproxy.sh | 14 ++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 haproxy/HAPROXY.md create mode 100644 haproxy/config/haproxy.cfg create mode 100644 haproxy/haproxy-compose.yaml create mode 100755 haproxy/reconfigure-haproxy.sh diff --git a/haproxy/HAPROXY.md b/haproxy/HAPROXY.md new file mode 100644 index 0000000..c99080c --- /dev/null +++ b/haproxy/HAPROXY.md @@ -0,0 +1,5 @@ +# HAPROXY +The Haproxy is used to route the requests to the diffrent backends & location +--> Only for local deployment +--> On kubernetes you can use an ingress for this + diff --git a/haproxy/config/haproxy.cfg b/haproxy/config/haproxy.cfg new file mode 100644 index 0000000..475b90e --- /dev/null +++ b/haproxy/config/haproxy.cfg @@ -0,0 +1,26 @@ +global + stats socket /var/run/api.sock user haproxy group haproxy mode 660 level admin expose-fd listeners + log stdout format raw local0 info + +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 myfrontend + bind :80 + default_backend webservers + +backend webservers + server s1 web1:8080 check + server s2 web2:8080 check + server s3 web3:8080 check \ No newline at end of file diff --git a/haproxy/haproxy-compose.yaml b/haproxy/haproxy-compose.yaml new file mode 100644 index 0000000..711f588 --- /dev/null +++ b/haproxy/haproxy-compose.yaml @@ -0,0 +1,8 @@ +version: 3 +services: + haproxy: + image: haproxy:alpine + ports: + - "80:80" + voluems: + - ./config/haproxy.cfg:/usr/local/etc/haproxy:ro \ No newline at end of file diff --git a/haproxy/reconfigure-haproxy.sh b/haproxy/reconfigure-haproxy.sh new file mode 100755 index 0000000..8bc493f --- /dev/null +++ b/haproxy/reconfigure-haproxy.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# Variables + +# Funcitons +function loadconfig { + source config/public + source config/private +} + +# Main Script +loadconfig + +echo $BACKEND_PORT \ No newline at end of file