-
-
Notifications
You must be signed in to change notification settings - Fork 607
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
Conversation
Seems fairly simple and it's a generic Nginx setting. My only concern is the downloading with Ansible docs say
Not exactly sure what the alternative is though or how much it matters. Obviously Trellis "downloads" many things during a provision but this won't be idempotent. |
Idempotent reporting. I was delightfully surprised that even with Copy module more flexible? Could users want a Capturing updates via partial hash in dest filename. If you stick with This assumes that the update would be at a new URL, NOT the same URL. The source URL doesn't strike me as official/canonical being in Cloudflare's support |
3ee16d5
to
7580f40
Compare
Updated:
Usage 1: wordpress_sites:
example.com:
ssl:
enabled: true
client_cert_url: 'https://example.com/origin-pull-ca.pem' Usage 2: ssl_client_cert_url: 'https://another-example.com/origin-pull-ca.pem'
wordpress_sites:
example.com:
ssl:
enabled: true Usage 3: ssl_client_cert_url: 'https://another-example.com/origin-pull-ca.pem'
wordpress_sites:
example.com:
ssl:
enabled: true
client_cert_url: false Usage 4: ssl_client_cert_url: 'https://another-example.com/origin-pull-ca.pem'
wordpress_sites:
example.com:
ssl:
enabled: true
client_cert_url: 'https://example.com/origin-pull-ca.pem' About using Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it even worth having the global option? Wondering if we should only allow the per site one and just let people define the same one if need be.
@@ -75,6 +75,15 @@ 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 and item.value.ssl.client_cert_url -%} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be ssl_client_cert_url
in the first one? Just confused why it's checking the same variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ssl_client_cert_url
was the global option, removed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the global option removed, I presume users would no longer disable client verification by setting client_cert_url: false
. Rather, they simply wouldn't define client_cert_url
for the relevant site.
If we don't need to check the bool
interpretation of client_cert_url
, could we make this change?
- {% if item.value.ssl.client_cert_url is defined and item.value.ssl.client_cert_url -%}
+ {% if item.value.ssl.client_cert_url is defined -%}
@@ -75,6 +75,15 @@ 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 and item.value.ssl.client_cert_url -%} | |||
ssl_client_certificate {{ nginx_ssl_path }}/{{ item.value.ssl.client_cert_url | hash('md5') }}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's two spaces before {
👾
ssl_verify_client on; | ||
|
||
{% elif ssl_client_cert_url is defined and not item.value.ssl.client_cert_url is defined -%} | ||
ssl_client_certificate {{ nginx_ssl_path }}/{{ ssl_client_cert_url | hash('md5') }}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto here too
7580f40
to
4ddcd8a
Compare
Will this be consider to be merged, or should I extract it to be a galaxy role? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tangrufus Thanks for your great work on this! I think it's ready to go if you're willing to make a few minor changes.
- include: nginx-client-cert.yml | ||
tags: wordpress-setup-nginx-client-cert | ||
notify: reload nginx | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two minor requests:
- Could you move this
include
task right after the other similar include tasks intasks/main.yml
? That placement strikes me as more consistent. I like the idea of avoiding nested includes when it's easy. - Let's omit the
notify
here. Nginx only needs to reload if the conf file produced by ourwordpress-site.conf.j2
changes. A change in the "Download client cert" task produces a new or renamed client cert, which in turn will trigger achanged
template task which already hasnotify: reload nginx
.
- name: Download client cert | ||
get_url: | ||
url: "{{ item.value.ssl.client_cert_url }}" | ||
dest: "{{ nginx_ssl_path }}/{{ item.value.ssl.client_cert_url | hash('md5') }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a user who happens upon the server's nginx_ssl_path
contents would find the filename more intuitive as client-4c1d4cc.crt
instead of 4c1d4ccad291c1ac1f230ad263c4196c
.
Could we make this change?
- dest: "{{ nginx_ssl_path }}/{{ item.value.ssl.client_cert_url | hash('md5') }}"
+ dest: "{{ nginx_ssl_path }}/client-{{ (item.value.ssl.client_cert_url | hash('md5'))[:7] }}.crt"
A similar filename change would be needed in wordpress-site.conf.j2
.
@@ -75,6 +75,15 @@ 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 and item.value.ssl.client_cert_url -%} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the global option removed, I presume users would no longer disable client verification by setting client_cert_url: false
. Rather, they simply wouldn't define client_cert_url
for the relevant site.
If we don't need to check the bool
interpretation of client_cert_url
, could we make this change?
- {% if item.value.ssl.client_cert_url is defined and item.value.ssl.client_cert_url -%}
+ {% if item.value.ssl.client_cert_url is defined -%}
4ddcd8a
to
e31612e
Compare
e31612e
to
fc8c95b
Compare
All set. Thanks! |
Wonderful! Thank you @tangrufus! |
Usage:
See: