Adding Listen in redirect site
The patch adds listen_address to redirect site definiton.
In case `listen_default_ports` is defined False and
listen_address is defined for redirection apache state adds
Listen directive to redirection site config.
Change-Id: Ie8dba33cdaf0fd41cbbb3c8a338fbc766cef005e
Related-PROD: PROD-24978
Related-PROD: PROD-24977
diff --git a/README.rst b/README.rst
index 6590959..706bf0b 100644
--- a/README.rst
+++ b/README.rst
@@ -173,6 +173,26 @@
limits:
request_body: 114688
+Apache redirect site definition.
+
+.. code-block:: yaml
+
+ apache:
+ server:
+ site:
+ openstack_web_redirect:
+ name: 'openstack_web_redirect'
+ enabled: true
+ type: 'redirect'
+ root: '/var/www/httproot'
+ host:
+ address: ${_param:apache_horizon_api_address}
+ name: ${_param:apache_horizon_api_host}
+ port: 80
+ redirect_mode: rewrite
+ target_url: 'https://%{SERVER_NAME}'
+ listen_address: '0.0.0.0'
+
Apache ssl cipher management
.. code-block:: yaml
diff --git a/apache/files/redirect.conf b/apache/files/redirect.conf
index 6ba4e6f..5d8f2dd 100644
--- a/apache/files/redirect.conf
+++ b/apache/files/redirect.conf
@@ -1,5 +1,26 @@
+{%- from "apache/map.jinja" import server with context %}
{%- set site = salt['pillar.get']('apache:server:site:'+site_name) %}
-<VirtualHost *:{% if site.host.port is defined %}{{ site.host.port }}{% else %}{% if site.ssl is defined %}443{% else %}80{% endif %}{% endif %}>
+
+{%- if site.get('host', {}).port is defined %}
+{%- set _port = site.host.port %}
+{%- else %}
+ {%- if site.ssl is defined %}
+{%- set _port = 443 %}
+ {%- else %}
+{%- set _port = 80 %}
+ {%- endif %}
+{%- endif %}
+
+{%- if not server.get('bind', {}).get('listen_default_ports', True) %}
+ {%- if site.listen_address is defined %}
+ {%- set listen_address = site.listen_address %}
+ {%- else %}
+ {%- set listen_address = '0.0.0.0' %}
+ {%- endif %}
+Listen {{ listen_address }}:{{ _port }}
+{%- endif %}
+
+<VirtualHost *:{{ _port }}>
{%- include "apache/files/_name.conf" %}
{%- include "apache/files/_ssl.conf" %}