From 1a86442b72347772c8a15f28750ba5bd21fd76d7 Mon Sep 17 00:00:00 2001
From: Michiel de Jong <michiel@unhosted.org>
Date: Wed, 8 Oct 2014 15:39:16 +0100
Subject: [PATCH] set hostname from environment during setup

---
 scripts/approve-user.sh  | 2 +-
 scripts/setup.sh         | 1 +
 templates/haproxy-1.part | 5 +----
 templates/haproxy-2.part | 6 ++----
 templates/haproxy-3.part | 6 ++++++
 5 files changed, 11 insertions(+), 9 deletions(-)
 create mode 100644 templates/haproxy-3.part

diff --git a/scripts/approve-user.sh b/scripts/approve-user.sh
index ec441d2..6eb3497 100755
--- a/scripts/approve-user.sh
+++ b/scripts/approve-user.sh
@@ -27,5 +27,5 @@ sed s/%HOSTNAME%/$1/g /data/infrastructure/templates/haproxy-frontend.part >> /d
 
 sed s/%HOSTNAME%/$1/g /data/infrastructure/templates/haproxy-backend.part | sed s/%IP%/$IP/g >> /data/server-wide/haproxy/backends.part
 
-cat /data/server-wide/haproxy/haproxy-1.part /data/server-wide/haproxy/certs.part /data/server-wide/haproxy/haproxy-2.part /data/server-wide/haproxy/frontends.part /data/server-wide/haproxy/backends.part > /data/server-wide/haproxy/haproxy.cfg
+cat /data/server-wide/haproxy/haproxy-1.part /data/server-wide/haproxy/hostname.part /data/server-wide/haproxy/haproxy-2.part /data/server-wide/haproxy/certs.part /data/server-wide/haproxy/haproxy-3.part /data/server-wide/haproxy/frontends.part /data/server-wide/haproxy/backends.part > /data/server-wide/haproxy/haproxy.cfg
 systemctl reload haproxy.service
diff --git a/scripts/setup.sh b/scripts/setup.sh
index 339dbfd..3a71a0b 100755
--- a/scripts/setup.sh
+++ b/scripts/setup.sh
@@ -19,6 +19,7 @@ rm /data/server-wide/haproxy/*.part
 touch /data/server-wide/haproxy/certs.part
 touch /data/server-wide/haproxy/frontends.part
 touch /data/server-wide/haproxy/backends.part
+hostname > /data/server-wide/haproxy/hostname.part
 cp /data/infrastructure/templates/haproxy-*.part /data/server-wide/haproxy/
 systemctl enable haproxy.service
 systemctl start  haproxy.service
diff --git a/templates/haproxy-1.part b/templates/haproxy-1.part
index 9493145..98656d8 100644
--- a/templates/haproxy-1.part
+++ b/templates/haproxy-1.part
@@ -17,7 +17,4 @@ defaults
 
 frontend https-in
 mode http
- bind *:443 ssl crt-list /haproxy-override/certs/list.txt crt /haproxy-override/approved-certs/coreos.dev/combined.pem
- reqadd X-Forwarded-Proto:\ https
-
-
+ bind *:443 ssl crt-list /haproxy-override/certs/list.txt crt /haproxy-override/approved-certs/
diff --git a/templates/haproxy-2.part b/templates/haproxy-2.part
index 45f44d9..84d9fb6 100644
--- a/templates/haproxy-2.part
+++ b/templates/haproxy-2.part
@@ -1,6 +1,4 @@
+/combined.pem
+ reqadd X-Forwarded-Proto:\ https
 
 
-default_backend coreos.dev
-    
-frontend http-in
-    bind *:80
diff --git a/templates/haproxy-3.part b/templates/haproxy-3.part
new file mode 100644
index 0000000..45f44d9
--- /dev/null
+++ b/templates/haproxy-3.part
@@ -0,0 +1,6 @@
+
+
+default_backend coreos.dev
+    
+frontend http-in
+    bind *:80
-- 
GitLab