Reimplement redirect domains

Signed-off-by: Tobias Manske <tobias.manske@mailbox.org>
This commit is contained in:
Tobias Manske 2022-06-18 16:19:04 +02:00
parent b449a279cd
commit 59fa4a73f2
Signed by: tobias
GPG Key ID: E83C743C1FC2F79A
3 changed files with 32 additions and 0 deletions

1
compose/05_caddy/.env Normal file
View File

@ -0,0 +1 @@
COMPOSE_PROJECT_NAME=caddy

View File

@ -0,0 +1,10 @@
{
auto_https off
}
{% for rule in redirect.hosts %}
http://{{ rule.from }} {
redir https://{{ rule.to }}{uri} permanent
}
{% endfor %}

View File

@ -0,0 +1,21 @@
---
version: "3.4"
services:
redirect:
image: caddy:2
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro,z
labels:
- "traefik.enable=true"
- "traefik.http.routers.caddyredir.rule={{ redirect.hosts | map(attribute='from') | map('regex_replace', '^(.*)$', 'Host(`\\1`)') | join(' || ') }}"
- "traefik.http.routers.caddyredir.entryPoints=websecure"
- "traefik.http.services.caddyredir.loadbalancer.server.port=80"
- "com.centurylinklabs.watchtower.scope=update"
restart: always
networks:
- gateway
networks:
gateway:
external: true