Commit 892ee511 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

apache-frontend: Fix various bugs and add unforgivable line

parent 0f066115
{% set cached_server_dict = {} -%} {% set cached_server_dict = {} -%}
{% set part_list = [] -%} {% set part_list = [] -%}
{% set TRUE_VALUES = ['y', 'yes', '1', 'true'] -%}
{% set generic_instance_parameter_dict = {'cache_access': cache_access,} -%} {% set generic_instance_parameter_dict = {'cache_access': cache_access,} -%}
[jinja2-template-base] [jinja2-template-base]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
...@@ -28,10 +29,12 @@ context = ...@@ -28,10 +29,12 @@ context =
{% set access_log = '/'.join([apache_log_directory, '%s_access_log' % slave_reference]) -%} {% set access_log = '/'.join([apache_log_directory, '%s_access_log' % slave_reference]) -%}
{% set error_log = '/'.join([apache_log_directory, '%s_error_log' % slave_reference]) -%} {% set error_log = '/'.join([apache_log_directory, '%s_error_log' % slave_reference]) -%}
# The slave use cache # The slave use cache
{% if 'enable_cache' in slave_instance -%} # Next line is forbidden and people who copy it will be hanged short
{% set enable_cache = ('' ~ slave_instance.get('enable_cache', '')).lower() in TRUE_VALUES -%}
{% if enable_cache -%}
{% do cached_server_dict.__setitem__(slave_instance.get('domain'), slave_instance.get('url')) -%} {% do cached_server_dict.__setitem__(slave_instance.get('domain'), slave_instance.get('url')) -%}
{% endif -%}
{% do slave_instance.__setitem__('url', cache_access) -%} {% do slave_instance.__setitem__('url', cache_access) -%}
{% endif -%}
{% do part_list.append(slave_section_title) -%} {% do part_list.append(slave_section_title) -%}
# Set up slave configuration file # Set up slave configuration file
[{{ slave_section_title }}] [{{ slave_section_title }}]
......
{% set TRUE_VALUES = ['y', 'yes', '1', 'true'] -%}
<VirtualHost *:{{ http_port }}> <VirtualHost *:{{ http_port }}>
ServerName {{ slave_parameter.get('domain', '') }} ServerName {{ slave_parameter.get('domain') }}
ServerAlias {{ slave_parameter.get('domain', '') }} ServerAlias {{ slave_parameter.get('domain') }}
SSLEngine on SSLEngine on
SSLProxyEngine on SSLProxyEngine on
# Rewrite part # Rewrite part
...@@ -25,12 +26,13 @@ ...@@ -25,12 +26,13 @@
{% endif -%} {% endif -%}
# If nothing exist : put a nice error # If nothing exist : put a nice error
# ErrorDocument 404 /notfound.html # ErrorDocument 404 /notfound.html
# Dadiboom
</VirtualHost> </VirtualHost>
<VirtualHost *:{{ https_port }}> <VirtualHost *:{{ https_port }}>
ServerName {{ slave_parameter.get('domain', '') }} ServerName {{ slave_parameter.get('domain') }}
ServerAlias {{ slave_parameter.get('domain', '') }} ServerAlias {{ slave_parameter.get('domain') }}
SSLProxyEngine on SSLProxyEngine on
# Rewrite part # Rewrite part
ProxyVia On ProxyVia On
...@@ -47,7 +49,9 @@ ...@@ -47,7 +49,9 @@
# Remove "Secure" from cookies, as backend may be https # Remove "Secure" from cookies, as backend may be https
Header edit Set-Cookie "(?i)^(.+);secure$" "$1" Header edit Set-Cookie "(?i)^(.+);secure$" "$1"
{% if 'https-only' in slave_parameter -%} # Next line is forbidden and people who copy it will be hanged short
{% set https_only = ('' ~ slave_parameter.get('https-only', '')).lower() in TRUE_VALUES -%}
{% if https_only in slave_parameter -%}
# Not using HTTPS? Ask that guy over there. # Not using HTTPS? Ask that guy over there.
# Dummy redirection to https. Note: will work only if https listens # Dummy redirection to https. Note: will work only if https listens
# on standard port (443). # on standard port (443).
......
...@@ -65,7 +65,7 @@ custom-group = $${dynamic-custom-group-template-slave-list:rendered} ...@@ -65,7 +65,7 @@ custom-group = $${dynamic-custom-group-template-slave-list:rendered}
[instance-parameter] [instance-parameter]
# Fetches parameters defined in SlapOS Master for this instance. # Fetches parameters defined in SlapOS Master for this instance.
# Always the same. # Always the same.
recipe = slapos.cookbook:slapconfiguration recipe = slapos.cookbook:slapconfiguration.serialised
computer = $${slap_connection:computer_id} computer = $${slap_connection:computer_id}
partition = $${slap_connection:partition_id} partition = $${slap_connection:partition_id}
url = $${slap_connection:server_url} url = $${slap_connection:server_url}
...@@ -106,7 +106,7 @@ extra-context = ...@@ -106,7 +106,7 @@ extra-context =
[dynamic-custom-personal-template-slave-list] [dynamic-custom-personal-template-slave-list]
< = jinja2-template-base < = jinja2-template-base
template = ${template-slave-list:target} template = ${template-slave-list:target}
filename = instance-slave-list.cfg filename = custom-personal-instance-slave-list.cfg
extensions = jinja2.ext.do extensions = jinja2.ext.do
extra-context = extra-context =
key apache_configuration_directory apache-directory:slave-configuration key apache_configuration_directory apache-directory:slave-configuration
...@@ -125,7 +125,7 @@ extra-context = ...@@ -125,7 +125,7 @@ extra-context =
[dynamic-custom-group-template-slave-list] [dynamic-custom-group-template-slave-list]
< = jinja2-template-base < = jinja2-template-base
template = ${template-custom-slave-list:target} template = ${template-custom-slave-list:target}
filename = instance-slave-list.cfg filename = custom-group-instance-slave-list.cfg
extensions = jinja2.ext.do extensions = jinja2.ext.do
extra-context = extra-context =
key apache_configuration_directory apache-directory:slave-configuration key apache_configuration_directory apache-directory:slave-configuration
...@@ -145,7 +145,7 @@ extra-context = ...@@ -145,7 +145,7 @@ extra-context =
[dynamic-default-template-slave-list] [dynamic-default-template-slave-list]
< = jinja2-template-base < = jinja2-template-base
template = ${template-custom-slave-list:target} template = ${template-custom-slave-list:target}
filename = instance-slave-list.cfg filename = default-instance-slave-list.cfg
extensions = jinja2.ext.do extensions = jinja2.ext.do
extra-context = extra-context =
key apache_configuration_directory apache-directory:slave-configuration key apache_configuration_directory apache-directory:slave-configuration
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment