From 12d5bc4649559d12809ead77183feee62a389a33 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 10 Aug 2022 04:52:29 -0400 Subject: [PATCH] refactor: use http and https as traefik entrypoints This makes it a bit more clear as to where things are being redirected for web containers. Also gate the https entrypoint behind the letsencrypt integration. --- plugins/traefik-vhosts/docker-args-process-deploy | 12 ++++++------ plugins/traefik-vhosts/templates/compose.yml.sigil | 10 ++++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/plugins/traefik-vhosts/docker-args-process-deploy b/plugins/traefik-vhosts/docker-args-process-deploy index e63a45a21..93572ead1 100755 --- a/plugins/traefik-vhosts/docker-args-process-deploy +++ b/plugins/traefik-vhosts/docker-args-process-deploy @@ -72,8 +72,8 @@ trigger-traefik-vhosts-docker-args-process-deploy() { done # add the labels for traefik here - # any `http:80` port mapping is treated as a `web` traefik entrypoint - # any `https:443` port mapping is treated as a `websecure` traefik entrypoint + # any `http:80` port mapping is treated as a `http` traefik entrypoint + # any `https:443` port mapping is treated as a `https` traefik entrypoint if [[ -n "$is_app_listening" ]]; then app_domains="$(plugn trigger domains-list "$APP")" if [[ -n "$app_domains" ]]; then @@ -90,7 +90,7 @@ trigger-traefik-vhosts-docker-args-process-deploy() { fi output="$output --label traefik.http.services.$APP-$PROC_TYPE.loadbalancer.server.port=$proxy_container_http_port" - output="$output --label traefik.http.routers.$APP-$PROC_TYPE.entrypoints=web" + output="$output --label traefik.http.routers.$APP-$PROC_TYPE.entrypoints=http" if [[ -n "$traefik_domains" ]]; then output="$output --label \"traefik.http.routers.$APP-$PROC_TYPE.rule=Host(\\\`$traefik_domains\\\`)\"" echo "# THIS FILE IS GENERATED BY DOKKU - DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN" >"$app_urls_path" @@ -105,10 +105,10 @@ trigger-traefik-vhosts-docker-args-process-deploy() { proxy_container_https_port="$proxy_container_https_port_candidate" fi - output="$output --label traefik.http.services.$APP-$PROC_TYPE-secure.loadbalancer.server.port=$proxy_container_https_port" - output="$output --label traefik.http.routers.$APP-$PROC_TYPE-secure.entrypoints=websecure" + output="$output --label traefik.http.services.$APP-$PROC_TYPE-https.loadbalancer.server.port=$proxy_container_https_port" + output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.entrypoints=https" if [[ -n "$traefik_domains" ]]; then - output="$output --label \"traefik.http.routers.$APP-$PROC_TYPE-secure.rule=Host(\\\`$traefik_domains\\\`)\"" + output="$output --label \"traefik.http.routers.$APP-$PROC_TYPE-https.rule=Host(\\\`$traefik_domains\\\`)\"" echo "# THIS FILE IS GENERATED BY DOKKU - DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN" >"$app_urls_path" xargs -I{} echo "https://{}" <<<"$(echo "${app_domains}" | tr ' ' '\n' | sort -u)" >>"$app_urls_path" fi diff --git a/plugins/traefik-vhosts/templates/compose.yml.sigil b/plugins/traefik-vhosts/templates/compose.yml.sigil index 7286334a3..4924b89a5 100644 --- a/plugins/traefik-vhosts/templates/compose.yml.sigil +++ b/plugins/traefik-vhosts/templates/compose.yml.sigil @@ -5,8 +5,10 @@ services: traefik: image: "{{ $.TRAEFIK_IMAGE }}" command: - - --entrypoints.web.address=:80 - - --entrypoints.websecure.address=:443 + - --entrypoints.http.address=:80 + {{ if $.TRAEFIK_LETSENCRYPT_EMAIL }} + - --entrypoints.https.address=:443 + {{ end }} - --providers.docker - --api={{ $.TRAEFIK_API_ENABLED }} - --api.dashboard={{ $.TRAEFIK_DASHBOARD_ENABLED }} @@ -25,7 +27,7 @@ services: # Dashboard - "traefik.http.routers.api.rule=Host(`{{ $.TRAEFIK_API_VHOST }}`)" - "traefik.http.routers.api.service=api@internal" - - "traefik.http.routers.api.entrypoints=web{{ if $.TRAEFIK_LETSENCRYPT_EMAIL }}secure{{ end }}" + - "traefik.http.routers.api.entrypoints={{ if $.TRAEFIK_LETSENCRYPT_EMAIL }}https{{ else }}http{{ end }}" - "traefik.http.routers.middlewares=auth" {{ if $.TRAEFIK_BASIC_AUTH }} - "traefik.http.middlewares.auth.basicauth.users={{ $.TRAEFIK_BASIC_AUTH }}" @@ -36,7 +38,7 @@ services: # global redirect to https - "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)" - - "traefik.http.routers.http-catchall.entrypoints=web" + - "traefik.http.routers.http-catchall.entrypoints=http" - "traefik.http.routers.http-catchall.middlewares=redirect-to-https" # middleware redirect