### Start Traefik and Sablier with Docker Compose Source: https://github.com/sablierapp/sablier-traefik-plugin/blob/main/examples/docker/README.md Use this command to start the Docker Compose stack for Traefik and Sablier. Ensure port 8080 is available. ```bash docker compose up ``` -------------------------------- ### Ingress with Middleware Configuration Source: https://context7.com/sablierapp/sablier-traefik-plugin/llms.txt Example of a Kubernetes Ingress resource that utilizes the Sablier middleware for routing and session management. ```APIDOC ## Ingress with Middleware ### Description This Kubernetes Ingress resource defines routing rules for `whoami.localhost` and applies a Traefik middleware (`default-whoami-dynamic@kubernetescrd`) configured via a Kubernetes CRD. This allows Traefik to manage traffic based on the Sablier plugin's configuration. ### Method N/A (Kubernetes Ingress definition) ### Endpoint N/A (Kubernetes Ingress definition) ### Parameters N/A (Kubernetes Ingress definition) ### Request Example ```yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: whoami-ingress annotations: traefik.ingress.kubernetes.io/router.entrypoints: web traefik.ingress.kubernetes.io/router.middlewares: default-whoami-dynamic@kubernetescrd spec: rules: - host: whoami.localhost http: paths: - path: / pathType: Prefix backend: service: name: whoami-service port: number: 80 ``` ### Response N/A (Kubernetes Ingress definition) ``` -------------------------------- ### Install Traefik Sablier Plugin Source: https://context7.com/sablierapp/sablier-traefik-plugin/llms.txt Add the plugin to your Traefik static configuration using a YAML file or CLI arguments. ```yaml # traefik.yml (static configuration) experimental: plugins: sablier: moduleName: "github.com/sablierapp/sablier-traefik-plugin" version: "v1.1.0" ``` ```bash # Or using CLI arguments: # --experimental.plugins.sablier.moduleName=github.com/sablierapp/sablier-traefik-plugin # --experimental.plugins.sablier.version=v1.1.0 ``` -------------------------------- ### Configure Dynamic Scaling Middleware Source: https://context7.com/sablierapp/sablier-traefik-plugin/llms.txt Configure the Sablier middleware for dynamic scaling, which displays a waiting page while containers start. Requires Sablier server URL and group name. ```yaml # dynamic-config.yml http: middlewares: my-sablier: plugin: sablier: # Required: Sablier server URL (must be reachable from Traefik) sablierUrl: http://sablier:10000 # Required: Group name for managing instances collectively group: my-app-group # Optional: Session duration before shutting down (e.g., "1m", "30s", "2h") sessionDuration: 1m # Optional: Ignore requests with specific User-Agent (returns HTTP 200) ignoreUserAgent: curl # Strategy: Dynamic (displays waiting page while starting) dynamic: displayName: My Services # Display name on waiting page showDetails: true # Show detailed status information theme: hacker-terminal # Theme: hacker-terminal, ghost, matrix refreshFrequency: 5s # How often page checks if ready routers: my-router: rule: Host(`myapp.localhost`) middlewares: - my-sablier service: my-service ``` -------------------------------- ### Install Sablier Plugin in Traefik Source: https://github.com/sablierapp/sablier-traefik-plugin/blob/main/README.md Add the plugin to your Traefik static configuration via YAML or CLI arguments. ```yaml experimental: plugins: sablier: moduleName: "github.com/sablierapp/sablier-traefik-plugin" version: "v1.1.0" ``` ```yaml --experimental.plugins.sablier.moduleName=github.com/sablierapp/sablier-traefik-plugin --experimental.plugins.sablier.version=v1.1.0 ``` -------------------------------- ### Multiple Container Groups Configuration Source: https://context7.com/sablierapp/sablier-traefik-plugin/llms.txt Configuration examples for managing multiple containers or groups simultaneously using the Sablier plugin in Traefik. ```APIDOC ## Multiple Container Groups ### Description This section provides YAML configurations for Traefik's HTTP service, demonstrating how to use the Sablier plugin to manage multiple containers or groups. It shows examples for managing individual containers by name and for managing dynamic groups based on labels. ### Method N/A (YAML configuration) ### Endpoint N/A (YAML configuration) ### Parameters N/A (YAML configuration) ### Request Example ```yaml # multiple-services.yml http: middlewares: # Multiple specific containers by name multi-service-sablier: plugin: sablier: sablierUrl: http://sablier:10000 # Comma-separated container names names: nginx-service, redis-cache, postgres-db sessionDuration: 5m dynamic: displayName: Full Stack Services showDetails: true # Or use groups for dynamic membership group-sablier: plugin: sablier: sablierUrl: http://sablier:10000 # All containers with sablier.group=production label group: production sessionDuration: 10m dynamic: displayName: Production Services theme: matrix routers: frontend: rule: Host(`app.localhost`) middlewares: - multi-service-sablier service: frontend-service api: rule: Host(`api.localhost`) middlewares: - group-sablier service: api-service ``` ### Response N/A (YAML configuration) ``` -------------------------------- ### Docker Compose Configuration for Sablier Source: https://context7.com/sablierapp/sablier-traefik-plugin/llms.txt Configure Traefik and Sablier services using Docker Compose. This setup enables the Sablier plugin for Traefik and defines middleware for a 'whoami' service, including session duration and display name. ```yaml services: traefik: image: traefik:v3.6.0 command: - --experimental.plugins.sablier.modulename=github.com/sablierapp/sablier-traefik-plugin - --experimental.plugins.sablier.version=v1.1.0 - --entryPoints.http.address=:80 - --providers.docker=true ports: - "8080:80" volumes: - '/var/run/docker.sock:/var/run/docker.sock' sablier: image: sablierapp/sablier:1.10.1 command: - start - --provider.name=docker volumes: - '/var/run/docker.sock:/var/run/docker.sock' whoami: image: traefik/whoami:latest labels: # Enable Sablier management for this container - sablier.enable=true - sablier.group=whoami # Configure the Sablier middleware - traefik.http.middlewares.whoami-sablier.plugin.sablier.group=whoami - traefik.http.middlewares.whoami-sablier.plugin.sablier.sablierUrl=http://sablier:10000 - traefik.http.middlewares.whoami-sablier.plugin.sablier.sessionDuration=1m - traefik.http.middlewares.whoami-sablier.plugin.sablier.dynamic.displayName=Whoami Service # Allow Traefik to route to stopped containers (requires v3.6.0+) - traefik.docker.allownonrunning=true # Define routing rules - traefik.http.routers.whoami.rule=Host(`whoami.localhost`) - traefik.http.routers.whoami.middlewares=whoami-sablier ``` -------------------------------- ### Kubernetes Middleware CRD for Sablier Source: https://context7.com/sablierapp/sablier-traefik-plugin/llms.txt Configure Sablier middleware using Traefik's Kubernetes CRD. This example defines a Deployment and Service for Sablier, and a Middleware CRD to attach the Sablier plugin to Ingress routes. ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: sablier-deployment namespace: kube-system spec: replicas: 1 selector: matchLabels: app: sablier template: metadata: labels: app: sablier spec: serviceAccountName: sablier containers: - name: sablier image: sablierapp/sablier:1.10.1 args: ["start", "--provider.name=kubernetes"] ports: - containerPort: 10000 --- apiVersion: v1 kind: Service metadata: name: sablier namespace: kube-system spec: selector: app: sablier ports: - protocol: TCP port: 10000 targetPort: 10000 --- # Middleware CRD for dynamic strategy apiVersion: traefik.io/v1alpha1 kind: Middleware metadata: name: whoami-dynamic namespace: default spec: plugin: sablier: names: deployment_default_whoami-deployment_1 sablierUrl: 'http://sablier.kube-system:10000' sessionDuration: 1m dynamic: displayName: 'Whoami Service' showDetails: true ``` -------------------------------- ### Middleware CRD for Blocking Strategy Source: https://context7.com/sablierapp/sablier-traefik-plugin/llms.txt Example of a Traefik Middleware Custom Resource Definition (CRD) for implementing a blocking strategy with the Sablier plugin. ```APIDOC ## Middleware CRD for Blocking Strategy ### Description This Kubernetes Custom Resource Definition (CRD) configures the Sablier plugin for Traefik to implement a blocking strategy. It specifies parameters like the Sablier server URL, group, session duration, and blocking timeout. ### Method N/A (Kubernetes CRD definition) ### Endpoint N/A (Kubernetes CRD definition) ### Parameters N/A (Kubernetes CRD definition) ### Request Example ```yaml apiVersion: traefik.io/v1alpha1 kind: Middleware metadata: name: whoami-blocking namespace: default spec: plugin: sablier: group: my-group sablierUrl: 'http://sablier.kube-system:10000' sessionDuration: 1m blocking: timeout: 30s ``` ### Response N/A (Kubernetes CRD definition) ``` -------------------------------- ### Go Plugin API - Middleware Creation Source: https://context7.com/sablierapp/sablier-traefik-plugin/llms.txt Demonstrates how to use the Sablier Go plugin API to programmatically create middleware handlers with various configuration options. ```APIDOC ## Go Plugin API ### Description The Sablier Go plugin API allows developers to create custom middleware handlers programmatically. It exposes `Config` struct for configuration and a `New` function to instantiate the middleware. ### Method N/A (Go code example) ### Endpoint N/A (Go code example) ### Parameters N/A (Go code example) ### Request Example ```go package main import ( "context" "net/http" sablier "github.com/sablierapp/sablier-traefik-plugin" ) func main() { // Create configuration config := sablier.CreateConfig() config.SablierURL = "http://sablier:10000" config.Group = "my-app-group" config.SessionDuration = "1m" // Configure dynamic strategy with waiting page showDetails := true config.Dynamic = &sablier.DynamicConfiguration{ DisplayName: "My Application", ShowDetails: &showDetails, Theme: "hacker-terminal", RefreshFrequency: "5s", } // Or configure blocking strategy instead // config.Blocking = &sablier.BlockingConfiguration{ // Timeout: "30s", // } // Optional: Ignore specific user agents config.IgnoreUserAgent = "curl" // Create the middleware nextHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Hello from backend!")) }) middleware, err := sablier.New(context.Background(), nextHandler, config, "my-middleware") if err != nil { panic(err) } // Use middleware in HTTP server http.ListenAndServe(":8080", middleware) } // Config struct fields: // - SablierURL: string - Sablier server URL // - Names: string - Comma-separated container names (deprecated, use Group) // - Group: string - Group name for collective management // - SessionDuration: string - Duration to keep instances running (e.g., "1m", "30s") // - Dynamic: *DynamicConfiguration - Dynamic strategy settings // - Blocking: *BlockingConfiguration - Blocking strategy settings // - IgnoreUserAgent: string - User agent to ignore (returns HTTP 200) ``` ### Response N/A (Go code example) ``` -------------------------------- ### Configure Sablier Middleware in Go Source: https://context7.com/sablierapp/sablier-traefik-plugin/llms.txt Programmatically create and configure the Sablier middleware using the provided Go API. ```go package main import ( "context" "net/http" sablier "github.com/sablierapp/sablier-traefik-plugin" ) func main() { // Create configuration config := sablier.CreateConfig() config.SablierURL = "http://sablier:10000" config.Group = "my-app-group" config.SessionDuration = "1m" // Configure dynamic strategy with waiting page showDetails := true config.Dynamic = &sablier.DynamicConfiguration{ DisplayName: "My Application", ShowDetails: &showDetails, Theme: "hacker-terminal", RefreshFrequency: "5s", } // Or configure blocking strategy instead // config.Blocking = &sablier.BlockingConfiguration{ // Timeout: "30s", // } // Optional: Ignore specific user agents config.IgnoreUserAgent = "curl" // Create the middleware nextHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Hello from backend!")) }) middleware, err := sablier.New(context.Background(), nextHandler, config, "my-middleware") if err != nil { panic(err) } // Use middleware in HTTP server http.ListenAndServe(":8080", middleware) } ``` -------------------------------- ### Configure Service Labels for Scaling Source: https://github.com/sablierapp/sablier-traefik-plugin/blob/main/README.md Apply labels to target services to enable Sablier scaling and configure Traefik routing. ```yaml whoami: image: acouvreur/whoami:v1.10.2 deploy: replicas: 0 labels: # Enable Sablier for this service - sablier.enable=true - sablier.group=my-group # Enable Traefik routing - traefik.enable=true # Use Swarm load balancer to prevent service eviction - traefik.docker.lbswarm=true # Define routing and attach the middleware - traefik.http.routers.whoami.rule=Host(`whoami.localhost`) - traefik.http.routers.whoami.middlewares=whoami-sablier@swarm - traefik.http.routers.whoami.service=whoami - traefik.http.services.whoami.loadbalancer.server.port=80 ``` -------------------------------- ### Define Middleware and Ingress in Kubernetes Source: https://context7.com/sablierapp/sablier-traefik-plugin/llms.txt Use these Kubernetes manifests to define a blocking middleware and apply it to an Ingress resource. ```yaml apiVersion: traefik.io/v1alpha1 kind: Middleware metadata: name: whoami-blocking namespace: default spec: plugin: sablier: group: my-group sablierUrl: 'http://sablier.kube-system:10000' sessionDuration: 1m blocking: timeout: 30s ``` ```yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: whoami-ingress annotations: traefik.ingress.kubernetes.io/router.entrypoints: web traefik.ingress.kubernetes.io/router.middlewares: default-whoami-dynamic@kubernetescrd spec: rules: - host: whoami.localhost http: paths: - path: / pathType: Prefix backend: service: name: whoami-service port: number: 80 ``` -------------------------------- ### Configure Traefik with Swarm Provider Source: https://github.com/sablierapp/sablier-traefik-plugin/blob/main/README.md Enable the Swarm provider and register the Sablier plugin in the Traefik service configuration. ```yaml traefik: image: traefik:v3.0.4 command: - --experimental.plugins.sablier.modulename=github.com/sablierapp/sablier-traefik-plugin - --experimental.plugins.sablier.version=v1.1.0 - --entryPoints.http.address=:80 - --providers.swarm=true - --providers.swarm.refreshSeconds=1 ports: - target: 80 published: 8080 volumes: - '/var/run/docker.sock:/var/run/docker.sock' ``` -------------------------------- ### Deploy Sablier with Middleware Configuration Source: https://github.com/sablierapp/sablier-traefik-plugin/blob/main/README.md Define the Sablier service and its associated middleware configuration within a Docker Compose file. ```yaml sablier: image: sablierapp/sablier:1.10.1 command: - start - --provider.name=swarm volumes: - '/var/run/docker.sock:/var/run/docker.sock' deploy: labels: - traefik.enable=true # Define the Sablier middleware here - traefik.http.middlewares.whoami-sablier.plugin.sablier.group=my-group - traefik.http.middlewares.whoami-sablier.plugin.sablier.sablierUrl=http://tasks.sablier:10000 - traefik.http.middlewares.whoami-sablier.plugin.sablier.sessionDuration=1m - traefik.http.middlewares.whoami-sablier.plugin.sablier.dynamic.displayName=Whoami Service - traefik.http.services.sablier.loadbalancer.server.port=10000 ``` -------------------------------- ### Configure Sablier Middleware Source: https://github.com/sablierapp/sablier-traefik-plugin/blob/main/README.md Define the Sablier middleware in your dynamic configuration with required and optional parameters. ```yaml http: middlewares: my-sablier: plugin: sablier: sablierUrl: http://sablier:10000 group: my-app-group sessionDuration: 1m ignoreUserAgent: curl dynamic: displayName: My Services showDetails: true theme: hacker-terminal refreshFrequency: 5s ``` -------------------------------- ### Configure Traefik for Local Plugin Development Source: https://github.com/sablierapp/sablier-traefik-plugin/blob/main/CONTRIBUTING.md Use this Docker Compose service configuration to mount the local plugin source code into a Traefik container for testing. ```yaml services: traefik: image: traefik:3.6.0 command: - --experimental.localPlugins.sablier.moduleName=github.com/sablierapp/sablier-traefik-plugin - --entryPoints.http.address=:80 - --providers.docker=true ports: - "8080:80" volumes: - '/var/run/docker.sock:/var/run/docker.sock' - '../..:/plugins-local/src/github.com/sablierapp/sablier-traefik-plugin' - './dynamic-config.yml:/etc/traefik/dynamic-config.yml' ``` -------------------------------- ### Docker Swarm Configuration for Sablier Source: https://context7.com/sablierapp/sablier-traefik-plugin/llms.txt Configure Traefik and Sablier for Docker Swarm, defining middleware centrally on the Sablier service. This approach is necessary because Traefik evicts services scaled to zero. ```yaml version: "3.7" services: traefik: image: traefik:v3.0.4 command: - --experimental.plugins.sablier.modulename=github.com/sablierapp/sablier-traefik-plugin - --experimental.plugins.sablier.version=v1.1.0 - --entryPoints.http.address=:80 - --providers.swarm=true - --providers.swarm.refreshSeconds=1 - --providers.swarm.allowemptyservices=true ports: - target: 80 published: 8080 volumes: - '/var/run/docker.sock:/var/run/docker.sock' sablier: image: sablierapp/sablier:1.10.1 command: - start - --provider.name=swarm volumes: - '/var/run/docker.sock:/var/run/docker.sock' deploy: labels: - traefik.enable=true # Define middleware on Sablier service (always running) - traefik.http.middlewares.whoami-sablier.plugin.sablier.group=my-group - traefik.http.middlewares.whoami-sablier.plugin.sablier.sablierUrl=http://tasks.sablier:10000 - traefik.http.middlewares.whoami-sablier.plugin.sablier.sessionDuration=1m - traefik.http.middlewares.whoami-sablier.plugin.sablier.dynamic.displayName=Whoami Service - traefik.http.services.sablier.loadbalancer.server.port=10000 whoami: image: acouvreur/whoami:v1.10.2 deploy: replicas: 0 # Start scaled to zero labels: - sablier.enable=true - sablier.group=my-group - traefik.enable=true - traefik.docker.lbswarm=true # Prevent service eviction - traefik.http.routers.whoami.rule=Host(`whoami.localhost`) - traefik.http.routers.whoami.middlewares=whoami-sablier@swarm - traefik.http.routers.whoami.service=whoami - traefik.http.services.whoami.loadbalancer.server.port=80 ``` -------------------------------- ### Configure Blocking Strategy Middleware Source: https://context7.com/sablierapp/sablier-traefik-plugin/llms.txt Configure the Sablier middleware for blocking strategy, which holds requests until containers are ready without displaying a waiting page. Useful for APIs. ```yaml # blocking-middleware.yml http: middlewares: api-sablier: plugin: sablier: sablierUrl: http://sablier:10000 group: api-services sessionDuration: 5m # Strategy: Blocking (waits up to timeout, then forwards request) blocking: timeout: 30s # Maximum wait time for containers to start routers: api-router: rule: Host(`api.localhost`) middlewares: - api-sablier service: api-service ``` -------------------------------- ### Configure Sablier Plugin using Docker Labels Source: https://github.com/sablierapp/sablier-traefik-plugin/blob/main/README.md Configure the Sablier plugin for a Docker service using labels. This method requires Traefik v3.6.0 or higher and allows Traefik to route to non-running containers. Ensure the `traefik.docker.allownonrunning` label is set to `true`. ```yaml whoami: image: traefik/whoami:latest labels: # Enable Sablier for this container - sablier.enable=true - sablier.group=whoami # Configure the Sablier middleware - traefik.http.middlewares.whoami-sablier.plugin.sablier.group=whoami - traefik.http.middlewares.whoami-sablier.plugin.sablier.sablierUrl=http://sablier:10000 - traefik.http.middlewares.whoami-sablier.plugin.sablier.sessionDuration=1m - traefik.http.middlewares.whoami-sablier.plugin.sablier.dynamic.displayName=Whoami Service # Allow Traefik to route to non-running containers - traefik.docker.allownonrunning=true # Define Traefik routing - traefik.http.routers.whoami.rule=Host(`whoami.localhost`) - traefik.http.routers.whoami.middlewares=whoami-sablier ``` -------------------------------- ### Stop Traefik and Sablier Docker Compose Stack Source: https://github.com/sablierapp/sablier-traefik-plugin/blob/main/examples/docker/README.md Use this command to stop and remove all containers created by the Docker Compose stack. This cleans up the environment. ```bash docker compose down ``` -------------------------------- ### Configure Sablier Plugin in Traefik Dynamic Configuration Source: https://github.com/sablierapp/sablier-traefik-plugin/blob/main/README.md Use this YAML configuration within Traefik's dynamic configuration to enable the Sablier plugin. It supports both 'dynamic' and 'blocking' strategies for session management. Ensure the Sablier service URL is reachable from Traefik. ```yaml http: middlewares: my-sablier: plugin: sablier: sablierUrl: http://sablier:10000 # Sablier service URL (must be reachable from Traefik) group: my-app-group # Group name for managing instances collectively sessionDuration: 1m # Session duration before shutting down instances # Only one strategy can be used at a time # Declare either `dynamic` or `blocking`, not both ignoreUserAgent: curl # (Optional) Ignore requests with User Agent header curl to not wake up container # Dynamic strategy: displays a waiting page dynamic: displayName: My Title # (Optional) Display name (defaults to middleware name) showDetails: true # (Optional) Show details for this middleware (defaults to Sablier server settings) theme: hacker-terminal # (Optional) Theme for the waiting page refreshFrequency: 5s # (Optional) Refresh frequency for the waiting page # Blocking strategy: waits for services to start (up to the timeout limit) # blocking: # timeout: 1m ``` -------------------------------- ### Manage Multiple Container Groups in Traefik Source: https://context7.com/sablierapp/sablier-traefik-plugin/llms.txt Configure middleware to manage multiple containers or groups simultaneously using names or group labels. ```yaml # multiple-services.yml http: middlewares: # Multiple specific containers by name multi-service-sablier: plugin: sablier: sablierUrl: http://sablier:10000 # Comma-separated container names names: nginx-service, redis-cache, postgres-db sessionDuration: 5m dynamic: displayName: Full Stack Services showDetails: true # Or use groups for dynamic membership group-sablier: plugin: sablier: sablierUrl: http://sablier:10000 # All containers with sablier.group=production label group: production sessionDuration: 10m dynamic: displayName: Production Services theme: matrix routers: frontend: rule: Host(`app.localhost`) middlewares: - multi-service-sablier service: frontend-service api: rule: Host(`api.localhost`) middlewares: - group-sablier service: api-service ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.