From f395aea7bebd1199c8d8e456084af07eee46344a Mon Sep 17 00:00:00 2001 From: waffles Date: Thu, 23 Feb 2023 13:22:18 -0800 Subject: [PATCH] If there's a preferred alternative domain, redirect root traffic there --- roles/frontend/templates/mastodon.j2 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/roles/frontend/templates/mastodon.j2 b/roles/frontend/templates/mastodon.j2 index b2e8b3a..0c61d56 100644 --- a/roles/frontend/templates/mastodon.j2 +++ b/roles/frontend/templates/mastodon.j2 @@ -59,6 +59,12 @@ server { add_header Strict-Transport-Security "max-age=31536000"; +{% if PREFERRED_ALT_DOMAIN and PREFERRED_ALT_DOMAIN != server %} + location = / { + rewrite / https://{{ PREFERRED_ALT_DOMAIN }}/ redirect; + } +{% endif %} + location / { try_files $uri @proxy; }