Skip to content

Commit d3f514a

Browse files
authored
Fix HSTS header omitted parts (#1592)
None seems to be replaced by an empty string by ansible. This can result in the Strict-Transport-Security header with a value like "max-age=1234; ; " or "max-age=1234; includeSubdomains; " Follow the ansible playbook guide example for omitting items from a list using the special omit variable.
1 parent 2517385 commit d3f514a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

roles/wordpress-setup/defaults/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ nginx_hsts_preload: false
1717

1818
# HSTS helpers
1919
hsts_max_age: "{{ item.value.ssl.hsts_max_age | default(nginx_hsts_max_age) }}"
20-
hsts_include_subdomains: "{{ item.value.ssl.hsts_include_subdomains | default(nginx_hsts_include_subdomains) | ternary('includeSubDomains', None) }}"
21-
hsts_preload: "{{ item.value.ssl.hsts_preload | default(nginx_hsts_preload) | ternary('preload', None) }}"
20+
hsts_include_subdomains: "{{ item.value.ssl.hsts_include_subdomains | default(nginx_hsts_include_subdomains) | ternary('includeSubDomains', omit) }}"
21+
hsts_preload: "{{ item.value.ssl.hsts_preload | default(nginx_hsts_preload) | ternary('preload', omit) }}"
2222

2323
# Fastcgi cache params
2424
nginx_cache_duration: 30s

roles/wordpress-setup/templates/wordpress-site.conf.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ server {
8686
ssl_buffer_size 1400; # 1400 bytes to fit in one MTU
8787

8888
{% if item.value.ssl.provider | default('manual') != 'self-signed' -%}
89-
add_header Strict-Transport-Security "max-age={{ [hsts_max_age, hsts_include_subdomains, hsts_preload] | reject('none') | join('; ') | trim }}";
89+
add_header Strict-Transport-Security "max-age={{ [hsts_max_age, hsts_include_subdomains, hsts_preload] | reject('equalto', omit) | join('; ') | trim }}";
9090
{% endif -%}
9191

9292
{% if item.value.ssl.client_cert_url is defined -%}

0 commit comments

Comments
 (0)