Skip to content

Commit ab0102c

Browse files
committed
[ADD] Logic for handling if not SSL cert was generated.
Signed-off-by: ecaepp <peace.patrick51@gmail.com>
1 parent 19f06c4 commit ab0102c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

templates/server.conf.j2

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# Managed by Ansible
22

33
server {
4-
server_name {{item.server_name}}; {# Required #}
5-
listen {{ item.listen_port }}; {# Required #}
4+
server_name {{item.server_name}};
5+
listen {{ item.listen_port }} ssl;
66

7-
root {{ item.root_dir }}/{{ item.server_name }}; {# Required #}
8-
index {{ item.index_name | default('index.html')}}; {# Required #}
7+
root {{ item.root_dir }}/{{ item.server_name }};
8+
index {{ item.index_name | default('index.html')}};
99

1010
{# Checks if `ssl` setting have been defined in the vhost file and configures them if they are #}
1111
# Configure Crypto Keys/Certificates/DH
12-
{% if item.ssl is defined and item.ssl != None%}
13-
ssl_certificate {{ item.ssl.cert_dir}}/{{ item.ssl.crt | default('server.crt')}};
14-
ssl_certificate_key {{ item.ssl.cert_dir}}/{{ item.ssl.key | default('server.key')}};
12+
{% if selfsigned_cert == true %}
13+
{%- if item.ssl is defined and item.ssl != None -%}
14+
ssl_certificate {{ item.ssl.crt | default('{{ item.ssl.cert_dir}}/server.crt')}};
15+
ssl_certificate_key {{ item.ssl.key | default('item.ssl.cert_dir}}/server.key')}};
16+
{%- endif %}
1517
{% endif %}
1618

1719
{# Checks if `security_headers` is set in vhost file and configures them if so #}

0 commit comments

Comments
 (0)