diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-02-15 08:03:59 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-02-15 08:03:59 +0200 |
commit | b91cb62deb6c2f3e72c4a5dd8004237929056729 (patch) | |
tree | 7f678b32c6587443fce346fd687ef535bfa4b7b6 | |
parent | 67de6e6151e38615e8c7935139e72d48a194664f (diff) | |
download | debian-ansible-b91cb62deb6c2f3e72c4a5dd8004237929056729.tar.gz |
apache_server: allow redirecting a site to another site
Sponsored-by: author
-rw-r--r-- | roles/apache_server/tasks/main.yml | 1 | ||||
-rw-r--r-- | roles/apache_server/templates/virtualhost.conf.tmpl | 5 |
2 files changed, 6 insertions, 0 deletions
diff --git a/roles/apache_server/tasks/main.yml b/roles/apache_server/tasks/main.yml index e01d01e..c4f348a 100644 --- a/roles/apache_server/tasks/main.yml +++ b/roles/apache_server/tasks/main.yml @@ -67,6 +67,7 @@ name: "{{ item }}" with_items: - ssl + - rewrite - name: create dirs for static site contents file: diff --git a/roles/apache_server/templates/virtualhost.conf.tmpl b/roles/apache_server/templates/virtualhost.conf.tmpl index 8d069ce..f8d4c47 100644 --- a/roles/apache_server/templates/virtualhost.conf.tmpl +++ b/roles/apache_server/templates/virtualhost.conf.tmpl @@ -8,6 +8,10 @@ ErrorLog /var/log/apache2/{{ item.domain }}/error.log CustomLog /var/log/apache2/{{ item.domain }}/access.log combined <Directory /srv/http/{{ item.domain }}> +{% if item.redirect|default(false) %} + Redirect permanent / "https://{{ item.redirect }}/" + Require all granted +{% else %} {% if item.letsencrypt|default(false) %} Redirect permanent / "https://{{ item.domain }}/" Require all granted @@ -23,6 +27,7 @@ Require all granted {% endif %} {% endif %} +{% endif %} </Directory> Alias /.well-known/ /srv/letsencrypt/{{ item.domain }}/ |