nginx/site: Include extra snippets to template

This commit is contained in:
Timo Makinen 2021-09-15 17:49:55 +00:00
parent 22470d8a49
commit c2e6c0f59d
3 changed files with 12 additions and 29 deletions

View file

@ -67,31 +67,3 @@
- role: nginx/site
site: zm.foo.sh
proxy: https://zm02.home.foo.sh/
tasks:
- name: create extra nginx config directories
file:
path: /etc/nginx/conf.d/www.foo.sh
state: directory
mode: 0755
owner: root
group: "{{ ansible_wheel }}"
- name: install redirects config for www.foo.sh
copy:
dest: /etc/nginx/conf.d/www.foo.sh/redirects.conf
content: |
location /collab/ { return 301 https://collab.foo.sh/; }
mode: 0644
owner: root
group: "{{ ansible_wheel }}"
notify: restart nginx
- name: install proxy config for www.foo.sh
copy:
dest: /etc/nginx/conf.d/www.foo.sh/proxy.conf
content: |
location /roles/ { proxy_pass https://static02.home.foo.sh/roles/; }
location /~ { proxy_pass https://static02.home.foo.sh/~; }
mode: 0644
owner: root
group: "{{ ansible_wheel }}"
notify: restart nginx

View file

@ -26,6 +26,7 @@ server {
ssl_certificate {{ tls_certs }}/{{ site }}-fullchain.crt;
ssl_certificate_key {{ tls_private }}/{{ site }}.key;
{% include "./{}.conf.j2".format(site) ignore missing %}
{% if redirect is defined %}
return 301 {{ redirect }};
{% elif proxy is defined %}
@ -41,7 +42,6 @@ server {
{% else %}
root /srv/web/{{ site }};
{% endif %}
include /etc/nginx/conf.d/{{ site }}/*.conf;
}
server {

View file

@ -0,0 +1,11 @@
location /collab/ {
return 301 https://collab.foo.sh/collab/;
}
location /roles/ {
proxy_pass https://static02.home.foo.sh/roles/;
}
location /~ {
proxy_pass https://static02.home.foo.sh/~;
}