From bb6bdc3d5bbd5739afa886a5d9b3eb51b4f5ca11 Mon Sep 17 00:00:00 2001 From: vincent Date: Mon, 23 May 2022 19:48:35 +0200 Subject: [PATCH] generalize http redirect --- traefik-ingress.nomad | 8 +++++--- traefik-local.nomad | 9 ++++++--- wikijs.nomad | 2 -- www.nomad | 4 ---- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/traefik-ingress.nomad b/traefik-ingress.nomad index 1c025a4..aa567b2 100644 --- a/traefik-ingress.nomad +++ b/traefik-ingress.nomad @@ -34,9 +34,6 @@ job "traefik-ingress" { name = "traefik-admin" port = "admin" tags = [ - "traefik.enable=true", - "traefik.http.routers.${NOMAD_JOB_NAME}_insecure.rule=Host(`${NOMAD_JOB_NAME}.ducamps.win`)", - "traefik.http.routers.${NOMAD_JOB_NAME}.tls.domains[0].sans=${NOMAD_JOB_NAME}.ducamps.win", ] } @@ -69,6 +66,11 @@ job "traefik-ingress" { [entryPoints] [entryPoints.web] address = ":80" + [entryPoints.web.http] + [entryPoints.web.http.redirections] + [entryPoints.web.http.redirections.entryPoint] + to = "websecure" + scheme = "https" [entryPoints.websecure] address = ":443" [entryPoints.traefik] diff --git a/traefik-local.nomad b/traefik-local.nomad index 63a92f2..e47246a 100644 --- a/traefik-local.nomad +++ b/traefik-local.nomad @@ -35,9 +35,6 @@ job "traefik-local" { name = "traefik-local-admin" port = "admin" tags = [ - "traefik.enable=true", - "traefik.http.routers.${NOMAD_JOB_NAME}_insecure.rule=Host(`${NOMAD_JOB_NAME}.ducamps.win`)", - "traefik.http.routers.${NOMAD_JOB_NAME}.tls.domains[0].sans=${NOMAD_JOB_NAME}.ducamps.win", ] } @@ -72,6 +69,12 @@ job "traefik-local" { [entryPoints] [entryPoints.web] address = ":80" + [entryPoints.web.http] + [entryPoints.web.http.redirections] + [entryPoints.web.http.redirections.entryPoint] + to = "websecure" + scheme = "https" + [entryPoints.websecure] address = ":443" [entryPoints.traefik] diff --git a/wikijs.nomad b/wikijs.nomad index a5b6a59..25c692b 100644 --- a/wikijs.nomad +++ b/wikijs.nomad @@ -30,8 +30,6 @@ job "wikijs" { "traefik.http.routers.${NOMAD_JOB_NAME}.rule=Host(`${NOMAD_JOB_NAME}.ducamps.win`)", "traefik.http.routers.${NOMAD_JOB_NAME}.tls.domains[0].sans=${NOMAD_JOB_NAME}.ducamps.win", "traefik.http.routers.${NOMAD_JOB_NAME}.tls.certresolver=myresolver", - "traefik.http.routers.${NOMAD_JOB_NAME}_insecure.middlewares=httpsRedirect", - "traefik.http.routers.${NOMAD_JOB_NAME}_insecure.rule=Host(`${NOMAD_JOB_NAME}.ducamps.win`)", ] diff --git a/www.nomad b/www.nomad index 0afc4ce..f770bd5 100644 --- a/www.nomad +++ b/www.nomad @@ -16,10 +16,6 @@ job "www" { "traefik.http.routers.${NOMAD_JOB_NAME}.rule=Host(`${NOMAD_JOB_NAME}.ducamps.win`)", "traefik.http.routers.${NOMAD_JOB_NAME}.tls.domains[0].sans=${NOMAD_JOB_NAME}.ducamps.win", "traefik.http.routers.${NOMAD_JOB_NAME}.tls.certresolver=myresolver", - "traefik.http.routers.${NOMAD_JOB_NAME}_insecure.entrypoints=web", - "traefik.http.routers.${NOMAD_JOB_NAME}_insecure.rule=Host(`${NOMAD_JOB_NAME}.ducamps.win`)", - "traefik.http.routers.${NOMAD_JOB_NAME}_insecure.middlewares=httpsRedirect", - "traefik.http.middlewares.httpsRedirect.redirectscheme.scheme=https", ] port = "http" }