Skip to content

Commit

Permalink
Add server side includes for nginx default sites
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Rodier committed Jan 6, 2024
1 parent 7dc244b commit 10ebc0c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions roles/nginx/templates/default-site.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ server {
add_header {{ sh.id }} {{ sh.value | quote }};
{% endfor %}

# Allow server side includes
ssi on;

# Add Content security policy
add_header Content-Security-Policy "{%- for c in csp.list %}{{ c.id }} {{ c.value | default(csp.default) }};{% endfor %}";

Expand Down
9 changes: 5 additions & 4 deletions roles/website-simple/tasks/install/default-content.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
register: index_page
ansible.builtin.stat:
path: /var/www/www.{{ network.domain }}/index.html
tags: website

- name: Create the website site root folder if needed
when: not index_page.stat.exists
tags: website
ansible.builtin.file:
path: '{{ path }}'
state: directory
Expand All @@ -20,19 +20,19 @@
- /var/www/www.{{ network.domain }}/js
loop_control:
loop_var: path
tags: website

- name: Get the locale information to build a default web site page.
when: not index_page.stat.exists
tags: website
ansible.builtin.set_fact:
website_language: '{{ website.locale | regex_replace("_.*", "") }}'
website_charset: '{{ website.locale | regex_replace(".*\.", "") }}'
tags: website

# Create the real one, and name it index.html. it will not be overwritten if you redeploy
# same for main.css and main.js
- name: Create a very simple fallback page.
when: not index_page.stat.exists
tags: website
ansible.builtin.template:
src: '{{ path.name }}'
dest: '{{ path.dest }}'
Expand All @@ -48,10 +48,10 @@
dest: /var/www/www.{{ network.domain }}/js/demo.js
loop_control:
loop_var: path
tags: website

- name: Remove the demo files if there is a real index file
when: index_page.stat.exists
tags: website
ansible.builtin.file:
path: '/var/www/www.{{ network.domain }}/{{ path }}'
state: absent
Expand All @@ -61,3 +61,4 @@
- js/demo.js
loop_control:
loop_var: path
tags: website
3 changes: 3 additions & 0 deletions roles/website-simple/templates/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ server {
add_header {{ sh.id }} {{ sh.value | quote }};
{% endfor %}

# Allow server side includes
ssi on;

# Add Content security policy
add_header Content-Security-Policy "{%- for c in csp.list %}{{ c.id }} {{ c.value | default(csp.default) }};{% endfor %}";

Expand Down

0 comments on commit 10ebc0c

Please sign in to comment.