From 9e24f50653023e497c89a66843d1554415df4403 Mon Sep 17 00:00:00 2001 From: Dan Anglin Date: Tue, 1 Aug 2023 02:45:28 +0100 Subject: [PATCH] fix(traefik): redirect root domain to Free Flow Redirect requests made to the root domain to Free Flow. --- templates/traefik/Dockerfile.gotmpl | 2 ++ .../dynamic_root_domain_redirect.yaml.gotmpl | 18 ++++++++++++++++++ templates/traefik/entrypoint.sh.gotmpl | 3 ++- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 templates/traefik/dynamic_root_domain_redirect.yaml.gotmpl diff --git a/templates/traefik/Dockerfile.gotmpl b/templates/traefik/Dockerfile.gotmpl index 90d509a..b94ed21 100644 --- a/templates/traefik/Dockerfile.gotmpl +++ b/templates/traefik/Dockerfile.gotmpl @@ -2,6 +2,8 @@ FROM traefik:{{ .Traefik.Version }} ADD traefik.yaml /flow/traefik/ +ADD dynamic_root_domain_redirect.yaml /tmp/dynamic_root_domain_redirect.yaml + ADD entrypoint.sh / RUN chmod +x /entrypoint.sh diff --git a/templates/traefik/dynamic_root_domain_redirect.yaml.gotmpl b/templates/traefik/dynamic_root_domain_redirect.yaml.gotmpl new file mode 100644 index 0000000..bec7015 --- /dev/null +++ b/templates/traefik/dynamic_root_domain_redirect.yaml.gotmpl @@ -0,0 +1,18 @@ +--- +http: + routers: + root-domain: + entryPoints: + - "https" + rule: "Host(`{{ .RootDomain }}`)" + middlewares: + - "redirect-root-to-freeflow" + service: noop@internal + tls: + certResolver: resolver + middlewares: + redirect-root-to-freeflow: + redirectRegex: + regex: "^(.*)" + replacement: "https://{{ .GoToSocial.Subdomain }}.{{ .RootDomain }}" + permanent: true diff --git a/templates/traefik/entrypoint.sh.gotmpl b/templates/traefik/entrypoint.sh.gotmpl index 25bd345..9a5cbca 100644 --- a/templates/traefik/entrypoint.sh.gotmpl +++ b/templates/traefik/entrypoint.sh.gotmpl @@ -8,7 +8,8 @@ chgrp {{ .FlowGID }} {{ .Traefik.SharedMountPoint }}/dynamic chmod a-rwx,u+rwx,g+rwx {{ .Traefik.SharedMountPoint }}/dynamic # Move any dynamic config to the new directory. -for f in $( find /tmp -mindepth 1 -maxdepth 1 -type f -iname '*dynamic*.yaml' -exec basename {} \; ); do +for f in $( find /tmp -mindepth 1 -maxdepth 1 -type f -iname 'dynamic*.yaml' -exec basename {} \; ); do + echo "INFO: Moving /tmp/${f} to {{ .Traefik.SharedMountPoint }}/dynamic/${f}..." mv -f /tmp/${f} {{ .Traefik.SharedMountPoint }}/dynamic/${f} done