feat: add www-non-www redirects to traefik

This commit is contained in:
Andras Bacsai
2024-01-04 14:14:40 +01:00
parent 64a7f27e37
commit 963c519c38
4 changed files with 19 additions and 4 deletions

View File

@@ -101,12 +101,27 @@ function generate_default_proxy_configuration(Server $server)
$labels = [
"traefik.enable=true",
"traefik.http.routers.traefik.entrypoints=http",
"traefik.http.routers.traefik.middlewares=traefik-basic-auth@file",
"traefik.http.routers.traefik.service=api@internal",
"traefik.http.services.traefik.loadbalancer.server.port=8080",
// Global Middlewares
"traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https",
"traefik.http.middlewares.gzip.compress=true",
// https WWW to non-WWW
"traefik.http.middlewares.https-www-to-non-www.redirectregex.regex=^https?://www\\.(.+)",
"traefik.http.middlewares.https-www-to-non-www.redirectregex.replacement=https://\$1",
"traefik.http.middlewares.https-www-to-non-www.redirectregex.permanent=true",
// https Non-WWW to WWW
"traefik.http.middlewares.https-non-www-to-www.redirectregex.regex=^https?://(?:www\\.)?(.+)",
"traefik.http.middlewares.https-non-www-to-www.redirectregex.replacement=https://www.\$\${1}",
"traefik.http.middlewares.https-non-www-to-www.redirectregex.permanent=true",
// http www to non-WWW
"traefik.http.middlewares.http-www-to-non-www.redirectregex.regex=^http://www\\.(.+)",
"traefik.http.middlewares.http-www-to-non-www.redirectregex.replacement=http://\$1",
"traefik.http.middlewares.http-www-to-non-www.redirectregex.permanent=true",
// http Non-WWW to WWW
"traefik.http.middlewares.http-non-www-to-www.redirectregex.regex=^http://(?:www\\.)?(.+)",
"traefik.http.middlewares.http-non-www-to-www.redirectregex.replacement=http://www.\$\${1}",
"traefik.http.middlewares.http-non-www-to-www.redirectregex.permanent=true",
];
$config = [
"version" => "3.8",