Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ debops.apache v0.1.0 - unreleased
Added
~~~~~

- Add :envvar:`apache__redirect_to_https` to control the role's default behaviour for
redirecting to https. [muelli_]

- Initial coding and design. [ypid_]

- Add/Set the default `Referrer Policy`_ to ``no-referrer`` and made it
Expand Down
7 changes: 7 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,13 @@ apache__https_enabled: '{{ ansible_local|d() and ansible_local.pki|d() and
(ansible_local.pki.enabled|d() | bool) and
apache__https_listen|length > 0 }}'

# ]]]
# .. envvar:: apache__redirect_to_https [[[
#
# This defines the default for each vhost's ``redirect_to_https`` variable.
# Defaults to ``True``.
apache__redirect_to_https: True

# ]]]
# PKI [[[
# ~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion docs/defaults-detailed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ Refer to the `Apache Redirect directive documentation`_ for details.
HTTPS, by default 301 Moved Permanently.

``redirect_to_https``
Optional, boolean. Defaults to ``True``
Optional, boolean. Defaults to ``apache__redirect_to_https``
If ``True``, redirect connection from HTTP to the HTTPS version of the site.
Set to ``False`` to allow to serve the website via HTTP and HTTPS and don't
redirect HTTP to HTTPS.
Expand Down
6 changes: 3 additions & 3 deletions templates/etc/apache2/sites-available/apache__tpl_macros.j2
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ ErrorLog ${APACHE_LOG_DIR}/{{ sanitized_name }}_error.log
{% set apache__tpl_status_enabled = item.status_enabled|d(apache__status_for_vhost_enabled) | bool %}
{{ get_server_status_directives(item, apache__tpl_status_enabled) -}}
{% if apache__tpl_status_enabled|bool and (
(mode == 'http' and (item.redirect_http|d() or item.redirect_to_https|d(https_enabled) | bool)) or
(mode == 'http' and (item.redirect_http|d() or item.redirect_to_https|d(apache__redirect_to_https) | bool)) or
(mode == 'https' and item.redirect_https|d())
) %}
RewriteEngine On
Expand All @@ -136,7 +136,7 @@ RewriteRule "^{{ item.status_location|d(apache__status_location) }}" "-" [L]
{% endif %}
{% if mode == 'http' and item.redirect_http|d() %}
{{ get_redirect(item.redirect_http_code|d(307), "/", item.redirect_http, apache__tpl_use_redirect_module) }}
{% elif mode == 'http' and item.redirect_to_https|d(https_enabled) | bool %}
{% elif mode == 'http' and item.redirect_to_https|d(apache__redirect_to_https) | bool %}
{{ get_redirect(item.redirect_to_https_with_code|d("301"), "/", "https://" + (debops__tpl_macros.get_yaml_list_for_elem(item.name) | from_yaml)[0], apache__tpl_use_redirect_module) }}
{% elif mode == 'https' and item.redirect_https|d() %}
{{ get_redirect(item.redirect_https_code|d(307), "/", item.redirect_https, apache__tpl_use_redirect_module) }}
Expand Down Expand Up @@ -255,7 +255,7 @@ Header {{ apache__tpl_directive_options }} X-Content-Type-Options "{{ item.http_
{% macro get_common_headers(item) %}{# [[[ #}
{% if item.http_clacks_overhead|d(apache__http_clacks_overhead|d(True)) | bool %}
{#
# Respect the will of the DebOps Creater.
# Respect the will of the DebOps Creator.
# Ref: https://github.com/debops/ansible-nginx/commit/d6cd455c68a7584b2592053fd98d3e539054e09a
#}
Header always set X-Clacks-Overhead "GNU Terry Pratchett"
Expand Down