Allow apache formula to set env varibles from mod_env and
mod_setenvif modules
Prod-Related: PROD-36176
Change-Id: Ibb735bf3759558677475d6f9b867efc6c7545b93
diff --git a/README.rst b/README.rst
index fb6b4ae..ced8f6f 100644
--- a/README.rst
+++ b/README.rst
@@ -186,6 +186,31 @@
limits:
request_body: 114688
+Apache environment modules (mod_env, mod_setendif).
+
+.. code-block:: yaml
+
+ apache:
+ server:
+ site:
+ horizon:
+ env:
+ passenv:
+ - variable: LC_ALL
+ enabled: False
+ setenv:
+ - variable: X-Forwarded-Proxy
+ value: somehost
+ enabled: False
+ unsetenv:
+ - variable: LC_LOCAL
+ envif:
+ browsermatch:
+ - rule: ^MSIE mozilla
+ setenvif:
+ - rule: X-Forwarded-Proto https HTTPS=1
+ enabled: False
+
Apache redirect site definition.
.. code-block:: yaml
diff --git a/apache/files/_core.conf b/apache/files/_core.conf
index 7aa0cea..f93d952 100644
--- a/apache/files/_core.conf
+++ b/apache/files/_core.conf
@@ -13,3 +13,50 @@
{%- if site.get('keepalive', {}).timeout is defined %}
KeepAliveTimeout {{ site.keepalive.timeout }}
{%- endif %}
+
+ {%- if site.env is defined %}
+ {%- for env_var in site.env.get('passenv', []) %}
+ {%- if env_var.get('enabled', True) %}
+ PassEnv {{ env_var.variable }}
+ {%- endif %}
+ {%- endfor %}
+ {%- for env_var in site.env.get('setenv', []) %}
+ {%- if env_var.get('enabled', True) %}
+ SetEnv {{ env_var.variable }} {{ env_var.value }}
+ {%- endif %}
+ {%- endfor %}
+ {%- for env_var in site.env.get('unsetenv', []) %}
+ {%- if env_var.get('enabled', True) %}
+ UnsetEnv {{ env_var.variable }}
+ {%- endif %}
+ {%- endfor %}
+ {%- endif %}
+
+ {%- if site.envif is defined %}
+ {%- for envif_var in site.envif.get('browsermatch', []) %}
+ {%- if envif_var.get('enabled', True) %}
+ BrowserMatch {{ envif_var.rule }}
+ {%- endif %}
+ {%- endfor %}
+ {%- for envif_var in site.envif.get('browsermatchnocase', []) %}
+ {%- if envif_var.get('enabled', True) %}
+ BrowserMatchNoCase {{ envif_var.rule }}
+ {%- endif %}
+ {%- endfor %}
+ {%- for envif_var in site.envif.get('setenvif', []) %}
+ {%- if envif_var.get('enabled', True) %}
+ SetEnvIf {{ envif_var.rule }}
+ {%- endif %}
+ {%- endfor %}
+ {%- for envif_var in site.envif.get('setenvifexpr', []) %}
+ {%- if envif_var.get('enabled', True) %}
+ SetEnvIfExpr {{ envif_var.rule }}
+ {%- endif %}
+ {%- endfor %}
+ {%- for envif_var in site.envif.get('setenvifnocase', []) %}
+ {%- if envif_var.get('enabled', True) %}
+ SetEnvIfNoCase {{ envif_var.rule }}
+ {%- endif %}
+ {%- endfor %}
+ {%- endif %}
+
diff --git a/tests/pillar/server_proxy.sls b/tests/pillar/server_proxy.sls
index ad6e703..d7d2c48 100644
--- a/tests/pillar/server_proxy.sls
+++ b/tests/pillar/server_proxy.sls
@@ -14,6 +14,21 @@
enabled: true
type: proxy
name: site_name
+ env:
+ passenv:
+ - variable: LC_ALL
+ enabled: False
+ setenv:
+ - variable: X-Forwarded-Proxy
+ enabled: False
+ unsetenv:
+ - variable: LC_ALL
+ envif:
+ browsermatch:
+ - rule: ^MSIE mozilla
+ enabled: False
+ setenvif:
+ - rule: X-Forwarded-Proto https HTTPS=1
proxy:
host: 127.0.0.1
port: 8080