Skip to content

Commit 2f0279c

Browse files
authored
🐛 Fix: Traefik www redirect (#893)
* wip * Add csi-s3 and have portainer use it * Change request @Hrytsuk 1GB max portainer volume size * Fix wrong filename * Fix registry local deploy * Traefik local deployment fixes * Traefik www redirect fixes * Remove Explicit www TLS domain * Enhance www redirect regex @Hrytsuk --------- Co-authored-by: Dustin Kaiser <[email protected]>
1 parent 177e82f commit 2f0279c

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

services/admin-panels/jupyter_server_config.py.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: skip-file
12
c.ServerApp.ip = '0.0.0.0'
23
c.ServerApp.port = 8888
34
c.ServerApp.open_browser = False

services/traefik/docker-compose.letsencrypt.dns.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ services:
33
traefik:
44
deploy:
55
labels:
6-
- traefik.http.routers.wwwsecure-catchall.tls.certresolver=myresolver
6+
- traefik.http.routers.www-catchall.tls.certresolver=myresolver
77
- traefik.http.routers.api.tls.certresolver=myresolver
88
- traefik.http.middlewares.ops_whitelist_ips.ipallowlist.sourcerange=${TRAEFIK_IPWHITELIST_SOURCERANGE}
99
# What follows is a tested workaround to ensure letsencrypt certificates for products' domains are generated

services/traefik/docker-compose.yml.j2

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@ services:
77
command:
88
- "--api=true"
99
- "--api.dashboard=true"
10+
- "--accesslog=true"
11+
- "--accesslog.format=json"
12+
- "--accesslog.fields.defaultmode=keep"
13+
- "--accesslog.fields.names.ClientUsername=keep"
14+
- "--accesslog.fields.headers.defaultmode=keep"
15+
- "--accesslog.fields.headers.names.User-Agent=keep"
16+
- "--accesslog.fields.headers.names.Authorization=drop"
17+
- "--accesslog.fields.headers.names.Content-Type=keep"
1018
- "--log.level=${OPS_TRAEFIK_LOGLEVEL}"
11-
- "--accesslog=false"
1219
- "--metrics.prometheus=true"
1320
- "--metrics.prometheus.addEntryPointsLabels=true"
1421
- "--metrics.prometheus.addServicesLabels=true"
@@ -18,9 +25,9 @@ services:
1825
- "--entryPoints.http.transport.respondingTimeouts.idleTimeout=21600s" #6h, for https://github.com/traefik/traefik/issues/10805
1926
- "--entryPoints.http.transport.respondingTimeouts.writeTimeout=21600s" #6h, for https://github.com/traefik/traefik/issues/10805
2027
- "--entryPoints.http.transport.respondingTimeouts.readTimeout=21600s" #6h, for https://github.com/traefik/traefik/issues/10805
21-
- --entrypoints.http.http.redirections.entrypoint.to=https
22-
- --entrypoints.http.http.redirections.entrypoint.scheme=https
23-
- --entrypoints.http.http.redirections.entrypoint.permanent=true
28+
- "--entrypoints.http.http.redirections.entrypoint.to=https"
29+
- "--entrypoints.http.http.redirections.entrypoint.scheme=https"
30+
- "--entrypoints.http.http.redirections.entrypoint.permanent=true"
2431
- '--entryPoints.postgres.address=:5432'
2532
- '--entryPoints.postgres2.address=:5433'
2633
- "--entryPoints.https.address=:443"
@@ -90,16 +97,12 @@ services:
9097
# via https://community.traefik.io/t/v2-2-8-global-redirect-www-to-non-www-with-http-to-https/7428
9198
# see also: https://community.traefik.io/t/get-a-valid-ssl-certificate-for-www-domains-via-traefik-and-lets-encrypt/2023
9299
# Global redirection: https (www.) to https
93-
- traefik.http.routers.wwwsecure-catchall.rule=HostRegexp(`(?P<host>(www\.).+)`)
94-
- traefik.http.routers.wwwsecure-catchall.entrypoints=https
95-
- traefik.http.routers.wwwsecure-catchall.tls=true
96-
- traefik.http.routers.wwwsecure-catchall.middlewares=wwwtohttps
97-
# middleware: http(s)://(www.) to https://
98-
- traefik.http.middlewares.wwwtohttps.redirectregex.regex=^https?://(?:www\.)?(.+)
99-
- traefik.http.middlewares.wwwtohttps.redirectregex.replacement=https://$${1}
100-
- traefik.http.middlewares.wwwtohttps.redirectregex.permanent=true
101-
# Explicit www domain certificate
102-
- traefik.http.routers.wwwsecure-catchall.tls.domains[0].main=www.${MACHINE_FQDN}
100+
- traefik.http.routers.www-catchall.rule=Host(`www.osparc.local`)
101+
- traefik.http.routers.www-catchall.priority=100000
102+
- traefik.http.routers.www-catchall.entrypoints=https,http
103+
- traefik.http.routers.www-catchall.tls=true
104+
- traefik.http.routers.www-catchall.middlewares=strip-www
105+
103106
###########################
104107
# basic authentication
105108
# Note: all dollar signs in the hash need to be doubled for escaping.
@@ -137,6 +140,12 @@ services:
137140
- traefik.http.middlewares.authenticated_platform_user.forwardauth.address=http://${WEBSERVER_HOST}:${WEBSERVER_PORT}/v0/auth:check
138141
- traefik.http.middlewares.authenticated_platform_user.forwardauth.trustForwardHeader=true
139142
- traefik.http.middlewares.authenticated_platform_user.forwardauth.authResponseHeaders=Set-Cookie,osparc-sc2
143+
#
144+
# middleware: http(s)://(www.) to https://
145+
- traefik.http.middlewares.strip-www.redirectregex.regex=^(https?)://www\.(.+)
146+
- traefik.http.middlewares.strip-www.redirectregex.replacement=$${1}://$${2}
147+
- traefik.http.middlewares.strip-www.redirectregex.permanent=true
148+
140149
networks:
141150
public: null
142151
monitored: null
@@ -145,7 +154,7 @@ services:
145154
deploy:
146155
placement:
147156
constraints:
148-
- node.labels.ops==true
157+
- node.labels.traefik==true
149158
labels:
150159
- traefik.enable=true
151160
- traefik.docker.network=${PUBLIC_NETWORK}

0 commit comments

Comments
 (0)