Skip to content

Commit 1dfee4c

Browse files
committed
fix: return 503 when ocis and office are down
We need to use file configuration in order to setup an empty service where the requests will be routed if the containters are down. Maintenance configuration will be also setup in there for convenience. Router configuration for the "unavailable" service is in the docker's labels because we want to skip the routing for traefik in case the dashboard is enabled, although it might not be needed.
1 parent e7e4c32 commit 1dfee4c

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

deployments/examples/ocis_full/collabora.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ services:
7676
- "traefik.http.routers.collabora.rule=Host(`${COLLABORA_DOMAIN:-collabora.owncloud.test}`)"
7777
- "traefik.http.routers.collabora.tls.certresolver=http"
7878
- "traefik.http.routers.collabora.service=collabora"
79-
- "traefik.http.routers.collabora.middlewares=maintenance"
79+
- "traefik.http.routers.collabora.middlewares=maintenance@file"
8080
- "traefik.http.services.collabora.loadbalancer.server.port=9980"
8181
logging:
8282
driver: ${LOG_DRIVER:-local}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
http:
3+
services:
4+
unavailable:
5+
loadBalancer:
6+
servers: {}
7+
middlewares:
8+
maintenance:
9+
plugin:
10+
traefik-maintenance:
11+
enabled: true
12+
filename: '/maintenance/content.txt'
13+
triggerFilename: '/maintenance/content.txt.trigger'
14+
httpResponseCode: 503
15+
httpContentType: 'text/plain; charset=utf-8'

deployments/examples/ocis_full/docker-compose.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ services:
2525
- "--entryPoints.https.transport.respondingTimeouts.writeTimeout=12h"
2626
- "--entryPoints.https.transport.respondingTimeouts.idleTimeout=3m"
2727
# docker provider (get configuration from container labels)
28+
- "--providers.docker=true"
2829
- "--providers.docker.endpoint=unix:///var/run/docker.sock"
2930
- "--providers.docker.exposedByDefault=false"
31+
- "--providers.file.directory=/etc/traefik/dynamic"
3032
# access log
3133
- "--accessLog=true"
3234
- "--accessLog.format=json"
@@ -40,6 +42,7 @@ services:
4042
volumes:
4143
- "${DOCKER_SOCKET_PATH:-/var/run/docker.sock}:/var/run/docker.sock:ro"
4244
- "certs:/certs"
45+
- "./config/traefik/:/etc/traefik/dynamic/"
4346
labels:
4447
- "traefik.enable=true"
4548
# defaults to admin:admin
@@ -49,12 +52,13 @@ services:
4952
- "traefik.http.routers.traefik.middlewares=traefik-auth"
5053
- "traefik.http.routers.traefik.tls.certresolver=http"
5154
- "traefik.http.routers.traefik.service=api@internal"
52-
# maintenance configuration
53-
- "traefik.http.middlewares.maintenance.plugin.traefik-maintenance.enabled=true"
54-
- "traefik.http.middlewares.maintenance.plugin.traefik-maintenance.httpResponseCode=503"
55-
- "traefik.http.middlewares.maintenance.plugin.traefik-maintenance.filename=/maintenance/content.txt"
56-
- "traefik.http.middlewares.maintenance.plugin.traefik-maintenance.triggerFilename=/maintenance/content.txt.trigger"
57-
- "traefik.http.middlewares.maintenance.plugin.traefik-maintenance.httpContentType=text/plain; charset=utf-8"
55+
# catchall configuration to return 503 for all requests if container is not available (except for traefik)
56+
- "traefik.http.routers.catchall.entrypoints=https"
57+
- "traefik.http.routers.catchall.rule=PathPrefix(`/`) && !Host(`${TRAEFIK_DOMAIN:-traefik.owncloud.test}`)"
58+
- "traefik.http.routers.catchall.priority=1"
59+
- "traefik.http.routers.catchall.middlewares=maintenance@file"
60+
- "traefik.http.routers.catchall.tls.certresolver=http"
61+
- "traefik.http.routers.catchall.service=unavailable@file"
5862
logging:
5963
driver: ${LOG_DRIVER:-local}
6064
restart: always

deployments/examples/ocis_full/ocis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ services:
6666
- "traefik.http.routers.ocis.rule=Host(`${OCIS_DOMAIN:-ocis.owncloud.test}`)"
6767
- "traefik.http.routers.ocis.tls.certresolver=http"
6868
- "traefik.http.routers.ocis.service=ocis"
69-
- "traefik.http.routers.ocis.middlewares=maintenance"
69+
- "traefik.http.routers.ocis.middlewares=maintenance@file"
7070
- "traefik.http.services.ocis.loadbalancer.server.port=9200"
7171
logging:
7272
driver: ${LOG_DRIVER:-local}

deployments/examples/ocis_full/onlyoffice.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ services:
7878
- "traefik.http.services.onlyoffice.loadbalancer.server.port=80"
7979
# websockets can't be opened when this is omitted
8080
- "traefik.http.middlewares.onlyoffice.headers.customrequestheaders.X-Forwarded-Proto=https"
81-
- "traefik.http.routers.onlyoffice.middlewares=onlyoffice,maintenance"
81+
- "traefik.http.routers.onlyoffice.middlewares=onlyoffice,maintenance@file"
8282
logging:
8383
driver: ${LOG_DRIVER:-local}
8484
restart: always

0 commit comments

Comments
 (0)