Solved mapping bugs

This commit is contained in:
2025-02-03 22:08:16 +01:00
parent 8a6adf3958
commit 7781083161
7 changed files with 61 additions and 31 deletions

View File

@@ -5,12 +5,16 @@
domain: "{{item.source}}"
loop: "{{domain_mappings}}"
- name: The domains for which a www. redirect will be implemented
debug:
var: domain_mappings
when: mode_debug | bool
- name: configure nginx redirect configurations
vars:
domain: "{{item.source}}"
target_domain: "{{item.target}}"
item: "{{item}}"
template:
src: redirect.domain.nginx.conf.j2
dest: "{{nginx.directories.http.servers}}{{ domain }}.conf"
loop: "{{domain_mappings}}"
dest: "{{nginx.directories.http.servers}}{{item.source}}.conf"
loop: "{{domain_mappings}}"
notify: restart nginx

View File

@@ -1,5 +1,8 @@
server {
{% set domain = item.source %}
{% set target = item.target %}
server_name {{domain}};
{% include 'roles/letsencrypt/templates/ssl_header.j2' %}
return 301 https://{{target_domain}}$request_uri;
return 301 https://{{target}}$request_uri;
}