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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user