From 6ac4638cfb83ee4a28b316fc646db9a594d5cc1d Mon Sep 17 00:00:00 2001
From: Michal Arbet <michal.arbet@ultimum.io>
Date: Mon, 28 Jun 2021 16:42:49 +0200
Subject: [PATCH] Trivial fix horizon's healthcheck when SSL turned on

This patch is fixing docker healthcheck for horizon
by changing value of horizon_listen_port, so
both apache's virtualhost and healthcheck will have
same correct port always. Also removing useless
apache's redirect as all redirects are done on
haproxy side.

Closes-Bug: #1933846
Change-Id: Ibb5ad1a5d1bbc74bcb62610d77852d8124c4a323
---
 ansible/group_vars/all.yml                           | 2 +-
 ansible/roles/horizon/templates/horizon.conf.j2      | 7 +------
 releasenotes/notes/bug-1933846-122a62e9724b638c.yaml | 5 +++++
 3 files changed, 7 insertions(+), 7 deletions(-)
 create mode 100644 releasenotes/notes/bug-1933846-122a62e9724b638c.yaml

diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml
index 393dce76be..ba48accf63 100644
--- a/ansible/group_vars/all.yml
+++ b/ansible/group_vars/all.yml
@@ -326,7 +326,7 @@ heat_api_cfn_listen_port: "{{ heat_api_cfn_port }}"
 
 horizon_port: "80"
 horizon_tls_port: "443"
-horizon_listen_port: "{{ horizon_port }}"
+horizon_listen_port: "{{ horizon_tls_port if horizon_enable_tls_backend | bool else horizon_port }}"
 
 influxdb_http_port: "8086"
 
diff --git a/ansible/roles/horizon/templates/horizon.conf.j2 b/ansible/roles/horizon/templates/horizon.conf.j2
index d7b25620e4..e9671a2d07 100644
--- a/ansible/roles/horizon/templates/horizon.conf.j2
+++ b/ansible/roles/horizon/templates/horizon.conf.j2
@@ -13,7 +13,7 @@ ServerSignature Off
 ServerTokens Prod
 TraceEnable off
 
-<VirtualHost *:{{ horizon_listen_port }}>
+<VirtualHost {{ api_interface_address }}:{{ horizon_listen_port }}>
     LogLevel warn
     ErrorLog /var/log/kolla/horizon/horizon.log
     LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b %D \"%{Referer}i\" \"%{User-Agent}i\"" logformat
@@ -50,11 +50,6 @@ TraceEnable off
 {% endif %}
 </VirtualHost>
 
-{# FIXME(yoctozepto): enabling of either tls will break the other if not enabled too #}
-{% if kolla_enable_tls_external | bool or kolla_enable_tls_internal | bool %}
-Header edit Location ^http://(.*)$ https://$1
-{% endif %}
-
 <IfModule mod_deflate.c>
     # Compress HTML, CSS, JavaScript, Json, Text, XML and fonts
     AddOutputFilterByType DEFLATE application/javascript
diff --git a/releasenotes/notes/bug-1933846-122a62e9724b638c.yaml b/releasenotes/notes/bug-1933846-122a62e9724b638c.yaml
new file mode 100644
index 0000000000..4df65a4175
--- /dev/null
+++ b/releasenotes/notes/bug-1933846-122a62e9724b638c.yaml
@@ -0,0 +1,5 @@
+---
+fixes:
+  - |
+    Fixes horizon's healthcheck when SSL is turned on.
+    `LP#1933846 <https://launchpad.net/bugs/1933846>`__