mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-30 23:38:13 +02:00
Solved Matomo domain bug and refactored
This commit is contained in:
16
roles/nginx-redirect-domain/README.md
Normal file
16
roles/nginx-redirect-domain/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Nginx Redirect Role
|
||||
|
||||
This Ansible role configures Nginx to perform 301 redirects from one domain to another. It handles SSL certificate retrieval for the source domains and sets up the Nginx configuration to redirect to the specified target domains.
|
||||
|
||||
## Role Variables
|
||||
|
||||
- `domain_mappings`: A list of objects with `source` and `target` properties specifying the domains to redirect from and to.
|
||||
- `administrator_email`: The email used for SSL certificate registration with Let's Encrypt.
|
||||
|
||||
## Dependencies
|
||||
|
||||
- `nginx-https`: A role for setting up HTTPS for Nginx
|
||||
- `letsencrypt`: A role for managing SSL certificates with Let's Encrypt
|
||||
|
||||
## Author Information
|
||||
This role was created in 2023 by [Kevin Veen-Birkenbach](https://www.veen.world/).
|
2
roles/nginx-redirect-domain/meta/main.yml
Normal file
2
roles/nginx-redirect-domain/meta/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- nginx-https
|
21
roles/nginx-redirect-domain/tasks/main.yml
Normal file
21
roles/nginx-redirect-domain/tasks/main.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
- name: "include task receive certbot certificate"
|
||||
include_role:
|
||||
name: nginx-https-recieve-certificate
|
||||
vars:
|
||||
domain: "{{item.source}}"
|
||||
loop: "{{domain_mappings}}"
|
||||
|
||||
- name: The domains for which a www. redirect will be implemented
|
||||
debug:
|
||||
var: domain_mappings
|
||||
when: enable_debug | bool
|
||||
|
||||
- name: configure nginx redirect configurations
|
||||
vars:
|
||||
item: "{{item}}"
|
||||
template:
|
||||
src: redirect.domain.nginx.conf.j2
|
||||
dest: "{{nginx.directories.http.servers}}{{item.source}}.conf"
|
||||
loop: "{{domain_mappings}}"
|
||||
notify: restart nginx
|
@@ -0,0 +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}}$request_uri;
|
||||
}
|
Reference in New Issue
Block a user