-
I struggle with setting up Sablier Middleware in Traefik. I use Docker Swarm + Traefik web-app docker-compose: version: '3'
services:
rust-book:
container_name: rust-book
image: peaceiris/mdbook:v0.4.28
stdin_open: true
tty: true
ports:
- "80"
networks:
- web
- rust-book
volumes:
- /home/swarm/books/rust-book:/book
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Warsaw
deploy:
labels:
- "traefik.enable=true"
- "traefik.http.routers.rust-book.rule=Host(`rust-book.home`)"
- "traefik.http.services.rust-book.loadbalancer.server.port=3000"
- "traefik.docker.network=web"
- "io.portainer.accesscontrol.users=admin"
- "traefik.http.routers.rust-book.tls=true"
- "sablier.enable=true" # I ADDED THIS
- "sablier.group=non-essential" # I ADDED THIS
- "traefik.docker.lbswarm=true" # I ADDED THIS
command:
- serve
- --hostname
- '0.0.0.0'
networks:
rust-book:
driver: overlay
attachable: true
name: rust-book
web:
external: true
name: web sablier docker-compose: version: "3.5"
services:
sablier:
image: acouvreur/sablier:1.6.1
container_name: sablier
ports:
- "80"
networks:
- web
- sablier
volumes:
- '/home/swarm/sablier/sablier.yaml:/etc/sablier/sablier.yml'
- '/var/run/docker.sock:/var/run/docker.sock'
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Warsaw
deploy:
labels:
- "traefik.enable=true"
- "traefik.http.routers.sablier.rule=Host(`sablier.home`)"
- "traefik.http.services.sablier.loadbalancer.server.port=10000"
- "traefik.docker.network=web"
- "io.portainer.accesscontrol.users=admin"
- "traefik.http.routers.sablier.tls=true"
command:
- start
- --provider.name=swarm
networks:
sablier:
driver: overlay
attachable: true
name: sablier
web: sablier.yml config: provider:
name: swarm
server:
port: 10000
base-path: /
storage:
file:
sessions:
default-duration: 5m
expiration-interval: 20s
logging:
level: info
strategy:
dynamic:
custom-themes-path:
show-details-by-default: true
default-theme: ghost
default-refresh-frequency: 5s
blocking:
default-timeout: 1m traefik-conf.yml: ### Static Configuration
log:
level: DEBUG
api:
dashboard: true
serversTransport:
insecureSkipVerify: true
rootCAs:
- /certs/rootCA.pem
certificatesResolvers:
rootCAs:
- /certs/rootCA.pem
entryPoints:
web:
address: ":80"
gitea-ssh:
address: ":222"
webhttp:
address: ":8081"
websecure:
address: ":443"
providers:
swarm:
exposedByDefault: false
file:
directory: /configuration/
watch: true
providers:
swarm:
exposedByDefault: false
file:
directory: /configuration/
watch: true
# For Sablier to work:
experimental:
plugins:
sablier:
moduleName: "github.com/acouvreur/sablier"
version: "v1.6.1"
http:
middlewares:
my-sablier:
plugin:
sablier:
group: non-essential
dynamic:
displayName: The service starts...
refreshFrequency: 5s
showDetails: "true"
theme: ghost
sablierUrl: https://sablier:10000
sessionDuration: 1m
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello @Cloufish ! You were very close of acheiving what you wanted! it looks like you're just missing the actual middleware on your route. While looking at the current documentation I can understand why it's confusing, the documentation is not showing the whole configuration. I will fix that soon. In the meantime, you can always check e2e tests that are located on the folder For traefik it will be See: https://github.com/acouvreur/sablier/tree/main/plugins/traefik/e2e/docker_swarm Now to the solution: Because you've setup you're middleware from the file provider, you can add the following deploy label to your service: services:
rust-book:
container_name: rust-book
image: peaceiris/mdbook:v0.4.28
stdin_open: true
tty: true
ports:
- "80"
networks:
- web
- rust-book
volumes:
- /home/swarm/books/rust-book:/book
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Warsaw
deploy:
labels:
- "traefik.enable=true"
- "traefik.http.routers.rust-book.rule=Host(`rust-book.home`)"
+ - "traefik.http.routers.rust-book.middlewares=my-sablier@file"
- "traefik.http.services.rust-book.loadbalancer.server.port=3000"
- "traefik.docker.network=web"
- "io.portainer.accesscontrol.users=admin"
- "traefik.http.routers.rust-book.tls=true"
- "sablier.enable=true" # I ADDED THIS
- "sablier.group=non-essential" # I ADDED THIS
- "traefik.docker.lbswarm=true" # I ADDED THIS
command:
- serve
- --hostname
- '0.0.0.0' The line
Will let know traefik to attach the middleware to your service. Once attached, if the middleware is properly configured, you should have a request issued to sablier before reaching your service! Let me know if that works. |
Beta Was this translation helpful? Give feedback.
Hello @Cloufish !
You were very close of acheiving what you wanted!
it looks like you're just missing the actual middleware on your route.
While looking at the current documentation I can understand why it's confusing, the documentation is not showing the whole configuration.
I will fix that soon.
In the meantime, you can always check e2e tests that are located on the folder
e2e
of each plugin.For traefik it will be
plugins/traefik/e2e/<provider>
(in your casedocker_swarm
).See: https://github.com/acouvreur/sablier/tree/main/plugins/traefik/e2e/docker_swarm
Now to the solution:
Because you've setup you're middleware from the file provider, you can add the following deploy label to your…