Adjust routers, add redirect on www. subdomain
All checks were successful
Build and Push Docker Image / build (push) Successful in 39s

This commit is contained in:
2026-04-16 04:15:09 -07:00
parent b8129f6aa5
commit 1ea315543b
2 changed files with 26 additions and 7 deletions

View File

@@ -28,11 +28,23 @@ job "blog" {
port = "http" port = "http"
tags = [ tags = [
# ----- router for the naked domain -----
"traefik.enable=true", "traefik.enable=true",
"traefik.http.routers.domainredirect.tls=true", "traefik.http.routers.blog.rule=Host(`${local.HOST}`)",
"traefik.http.routers.domainredirect.entrypoints=websecure", "traefik.http.routers.blog.entrypoints=websecure",
"traefik.http.routers.domainredirect.rule=Host(`${local.HOST}`)", "traefik.http.routers.blog.tls=true",
]
# ----- router for the www domain (new) -----
"traefik.http.routers.blog-www.rule=Host(`www.${local.HOST}`)",
"traefik.http.routers.blog-www.entrypoints=websecure",
"traefik.http.routers.blog-www.tls=true",
"traefik.http.routers.blog-www.middlewares=redirect-www-to-root",
# ----- middleware that does the 301 redirect -----
"traefik.http.middlewares.redirect-www-to-root.redirectregex.regex=^https?://www\\.${local.HOST}(.*)",
"traefik.http.middlewares.redirect-www-to-root.redirectregex.replacement=https://${local.HOST}$${1}",
"traefik.http.middlewares.redirect-www-to-root.redirectregex.permanent=true"
]
} }
task "blog" { task "blog" {

View File

@@ -102,9 +102,16 @@
"Name": "blog", "Name": "blog",
"Tags": [ "Tags": [
"traefik.enable=true", "traefik.enable=true",
"traefik.http.routers.domainredirect.tls=true", "traefik.http.routers.blog.rule=Host(`cbraaten.dev`)",
"traefik.http.routers.domainredirect.entrypoints=websecure", "traefik.http.routers.blog.entrypoints=websecure",
"traefik.http.routers.domainredirect.rule=Host(`cbraaten.dev`)" "traefik.http.routers.blog.tls=true",
"traefik.http.routers.blog-www.rule=Host(`www.cbraaten.dev`)",
"traefik.http.routers.blog-www.entrypoints=websecure",
"traefik.http.routers.blog-www.tls=true",
"traefik.http.routers.blog-www.middlewares=redirect-www-to-root",
"traefik.http.middlewares.redirect-www-to-root.redirectregex.regex=^https?://www\\.cbraaten.dev(.*)",
"traefik.http.middlewares.redirect-www-to-root.redirectregex.replacement=https://cbraaten.dev${1}",
"traefik.http.middlewares.redirect-www-to-root.redirectregex.permanent=true"
], ],
"CanaryTags": null, "CanaryTags": null,
"EnableTagOverride": false, "EnableTagOverride": false,