Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WordPress Setup: Add Nginx ssl_client_certificate #869

Merged
merged 1 commit into from
Sep 10, 2017
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
2 changes: 2 additions & 0 deletions roles/wordpress-setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
tags: wordpress-setup-database
- include: self-signed-certificate.yml
tags: wordpress-setup-self-signed-certificate
- include: nginx-client-cert.yml
tags: wordpress-setup-nginx-client-cert

- name: Create web root
file:
Expand Down
8 changes: 8 additions & 0 deletions roles/wordpress-setup/tasks/nginx-client-cert.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: Download client cert
get_url:
url: "{{ item.value.ssl.client_cert_url }}"
dest: "{{ nginx_ssl_path }}/client-{{ (item.value.ssl.client_cert_url | hash('md5'))[:7] }}.crt"
mode: 0640
with_dict: "{{ wordpress_sites }}"
when: ssl_enabled and item.value.ssl.client_cert_url is defined
5 changes: 5 additions & 0 deletions roles/wordpress-setup/templates/wordpress-site.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ server {

add_header Strict-Transport-Security "max-age={{ [hsts_max_age, hsts_include_subdomains, hsts_preload] | reject('none') | join('; ') }}";

{% if item.value.ssl.client_cert_url is defined -%}
ssl_verify_client on;
ssl_client_certificate {{ nginx_ssl_path }}/client-{{ (item.value.ssl.client_cert_url | hash('md5'))[:7] }}.crt;
{% endif -%}

{% if item.value.ssl.provider | default('manual') == 'manual' and item.value.ssl.cert is defined and item.value.ssl.key is defined -%}
ssl_certificate {{ nginx_path }}/ssl/{{ item.value.ssl.cert | basename }};
ssl_certificate_key {{ nginx_path }}/ssl/{{ item.value.ssl.key | basename }};
Expand Down