From 67e0c4a80e1b31c574f74ae5327b4378ebd2f396 Mon Sep 17 00:00:00 2001
From: Arne Oslebo <arne.oslebo@uninett.no>
Date: Thu, 1 Oct 2020 14:52:12 +0200
Subject: [PATCH] use tcp mode for nifi and elastic

---
 roles/build/files/haproxy-entrypoint.sh | 17 +++++++++++++++++
 roles/haproxy/templates/haproxy.cfg.j2  |  4 ++--
 2 files changed, 19 insertions(+), 2 deletions(-)
 create mode 100755 roles/build/files/haproxy-entrypoint.sh

diff --git a/roles/build/files/haproxy-entrypoint.sh b/roles/build/files/haproxy-entrypoint.sh
new file mode 100755
index 0000000..8b2093b
--- /dev/null
+++ b/roles/build/files/haproxy-entrypoint.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+set -e
+
+# first arg is `-f` or `--some-option`
+if [ "${1#-}" != "$1" ]; then
+	set -- haproxy "$@"
+fi
+
+if [ "$1" = 'haproxy' ]; then
+	shift # "haproxy"
+	# if the user wants "haproxy", let's add a couple useful flags
+	#   -W  -- "master-worker mode" (similar to the old "haproxy-systemd-wrapper"; allows for reload via "SIGUSR2")
+	#   -db -- disables background mode
+	set -- haproxy -W -db "$@"
+fi
+
+exec "$@"
diff --git a/roles/haproxy/templates/haproxy.cfg.j2 b/roles/haproxy/templates/haproxy.cfg.j2
index 6153991..67a02e7 100644
--- a/roles/haproxy/templates/haproxy.cfg.j2
+++ b/roles/haproxy/templates/haproxy.cfg.j2
@@ -21,7 +21,7 @@ listen stats
 
 listen nifiserv
 	bind *:9443
-	mode http
+	mode tcp
 	maxconn 5000
 	fullconn 5000
 	balance source
@@ -32,7 +32,7 @@ listen nifiserv
 
 listen odfeserv
         bind *:9200
-        mode http
+        mode tcp
         maxconn 5000
         fullconn 5000
         balance source
-- 
GitLab