souin icon indicating copy to clipboard operation
souin copied to clipboard

Souin Traefik configuration error

Open aroransh96 opened this issue 4 months ago • 1 comments

Hello I am getting the following error in traefik logs when starting jellyfin with Souin as Middleware.

traefik  | 2025-08-24T21:48:47+05:30 DBG github.com/traefik/traefik/v3/pkg/server/service/service.go:319 > Creating load-balancer entryPointName=web routerName=jellyfin@file serviceName=jellyfin@file
traefik  | 2025-08-24T21:48:47+05:30 DBG github.com/traefik/traefik/v3/pkg/server/service/service.go:362 > Creating server URL=http://192.168.1.2:8096 entryPointName=web routerName=jellyfin@file serverIndex=0 serviceName=jellyfin@file
traefik  | 2025-08-24T21:48:47+05:30 DBG github.com/traefik/traefik/v3/pkg/middlewares/observability/service.go:26 > Added outgoing tracing middleware entryPointName=web middlewareName=tracing middlewareType=TracingService routerName=jellyfin@file serviceName=jellyfin@file
traefik  | 2025-08-24T21:48:47+05:30 ERR fmt/print.go:305 > plugins-storage/sources/gop-2918251026/src/github.com/darkweak/souin/plugins/traefik/main.go:287:18: panic: github.com/darkweak/souin/plugins/traefik.parseIntSlice(...) module=github.com/darkweak/souin plugin=plugin-souin runtime=
traefik  | 2025-08-24T21:48:47+05:30 ERR fmt/print.go:305 > plugins-storage/sources/gop-2918251026/src/github.com/darkweak/souin/plugins/traefik/main.go:63:19: panic: github.com/darkweak/souin/plugins/traefik.parseConfiguration(...) module=github.com/darkweak/souin plugin=plugin-souin runtime=
traefik  | 2025-08-24T21:48:47+05:30 ERR fmt/print.go:305 > plugins-storage/sources/gop-2918251026/src/github.com/darkweak/souin/plugins/traefik/main.go:303:26: panic: github.com/darkweak/souin/plugins/traefik.New(...) module=github.com/darkweak/souin plugin=plugin-souin runtime=
traefik  | 2025-08-24T21:48:47+05:30 ERR github.com/traefik/traefik/v3/pkg/safe/routine.go:64 > Error in Go routine error={}
traefik  | 2025-08-24T21:48:47+05:30 ERR github.com/traefik/traefik/v3/pkg/safe/routine.go:65 > Stack: goroutine 102 [running]:
traefik  | runtime/debug.Stack()
traefik  | 	runtime/debug/stack.go:26 +0x5e
traefik  | github.com/traefik/traefik/v3/pkg/safe.defaultRecoverGoroutine({0x79deaa0, 0xc00519a2e8})
traefik  | 	github.com/traefik/traefik/v3/pkg/safe/routine.go:65 +0x85
traefik  | github.com/traefik/traefik/v3/pkg/safe.GoWithRecover.func1.1()
traefik  | 	github.com/traefik/traefik/v3/pkg/safe/routine.go:56 +0x34
traefik  | panic({0x79deaa0?, 0xc00519a2e8?})
traefik  | 	runtime/panic.go:792 +0x132
traefik  | github.com/traefik/yaegi/interp.runCfg.func1()
traefik  | 	github.com/traefik/[email protected]/interp/run.go:226 +0x1ae
traefik  | panic({0x79deaa0?, 0xc00519a2e8?})
traefik  | 	runtime/panic.go:792 +0x132
traefik  | github.com/traefik/yaegi/interp.runCfg.func1()
traefik  | 	github.com/traefik/[email protected]/interp/run.go:226 +0x1ae
traefik  | panic({0x79deaa0?, 0xc00519a2e8?})
traefik  | 	runtime/panic.go:792 +0x132
traefik  | github.com/traefik/yaegi/interp.runCfg.func1()
traefik  | 	github.com/traefik/[email protected]/interp/run.go:226 +0x1ae
traefik  | panic({0x79deaa0?, 0xc00519a2e8?})
traefik  | 	runtime/panic.go:792 +0x132
traefik  | github.com/traefik/yaegi/interp.typeAssert.func3(0xc004cdf970)
traefik  | 	github.com/traefik/[email protected]/interp/run.go:478 +0x5f4
traefik  | github.com/traefik/yaegi/interp.runCfg(0xc003a40a00, 0xc004cdf970, 0xc004ce9d80?, 0x6b464e0?)
traefik  | 	github.com/traefik/[email protected]/interp/run.go:234 +0x265
traefik  | github.com/traefik/yaegi/interp.call.func9(0xc004cdf810)
traefik  | 	github.com/traefik/[email protected]/interp/run.go:1401 +0x7cc
traefik  | github.com/traefik/yaegi/interp.runCfg(0xc0039e3e00, 0xc004cdf810, 0xc004ce9fd0?, 0x6f89d40?)
traefik  | 	github.com/traefik/[email protected]/interp/run.go:234 +0x265
traefik  | github.com/traefik/yaegi/interp.call.func9(0xc004cdf760)
traefik  | 	github.com/traefik/[email protected]/interp/run.go:1401 +0x7cc
traefik  | github.com/traefik/yaegi/interp.runCfg(0xc003a46dc0, 0xc004cdf760, 0xc004b4c780?, 0x68aac40?)
traefik  | 	github.com/traefik/[email protected]/interp/run.go:234 +0x265
traefik  | github.com/traefik/yaegi/interp.genFunctionWrapper.func1.1({0xc005172840, 0x4, 0x8?})
traefik  | 	github.com/traefik/[email protected]/interp/run.go:1042 +0x805
traefik  | reflect.Value.call({0xc004b60230?, 0xc002723aa0?, 0xc004ceadd0?}, {0x7da861d, 0x4}, {0xc004ceaeb8, 0x4, 0x16?})
traefik  | 	reflect/value.go:584 +0xca6
traefik  | reflect.Value.Call({0xc004b60230?, 0xc002723aa0?, 0xc002723aa0?}, {0xc004ceaeb8?, 0xc004b4aa40?, 0xc002723dd0?})
traefik  | 	reflect/value.go:368 +0xb9
traefik  | github.com/traefik/traefik/v3/pkg/plugins.yaegiMiddlewareBuilder.newHandler({{0xc004b60230, 0xc002723aa0, 0x13}, {0xc004b4aa40, 0xc002723dd0, 0x13}}, {0x8ac12e8?, 0xc002b55290?}, {0x8a208a0, 0xc00515f960}, ...)
traefik  | 	github.com/traefik/traefik/v3/pkg/plugins/middlewareyaegi.go:63 +0x296
traefik  | github.com/traefik/traefik/v3/pkg/plugins.(*YaegiMiddleware).NewHandler(0x5?, {0x8ac12e8?, 0xc002b55290}, {0x8a208a0?, 0xc00515f960?})
traefik  | 	github.com/traefik/traefik/v3/pkg/plugins/middlewareyaegi.go:121 +0xeb
traefik  | github.com/traefik/traefik/v3/pkg/server/middleware.newTraceablePlugin(...)
traefik  | 	github.com/traefik/traefik/v3/pkg/server/middleware/plugins.go:45
traefik  | github.com/traefik/traefik/v3/pkg/server/middleware.(*Builder).buildConstructor.func25({0x8a208a0?, 0xc00515f960?})
traefik  | 	github.com/traefik/traefik/v3/pkg/server/middleware/middlewares.go:386 +0x4f
traefik  | github.com/traefik/traefik/v3/pkg/server/middleware.(*Builder).buildConstructor.WrapMiddleware.func30({0x8a208a0?, 0xc00515f960?})
traefik  | 	github.com/traefik/traefik/v3/pkg/middlewares/observability/middleware.go:26 +0x45
traefik  | github.com/traefik/traefik/v3/pkg/server/middleware.(*Builder).BuildChain.func1({0x8a208a0, 0xc00515f960})
traefik  | 	github.com/traefik/traefik/v3/pkg/server/middleware/middlewares.go:89 +0xe5
traefik  | github.com/containous/alice.Chain.Then({{0xc005143be0?, 0x8ac12e8?, 0xc002b54fc0?}}, {0x8a208a0?, 0xc00515f960?})
traefik  | 	github.com/containous/[email protected]/chain.go:51 +0x89
traefik  | github.com/traefik/traefik/v3/pkg/server/router.(*Manager).buildHTTPHandler(0xc004cebd80, {0x8ac12e8, 0xc002b54fc0}, 0xc004cc6690, {0xc003e281b0, 0xd})
traefik  | 	github.com/traefik/traefik/v3/pkg/server/router/router.go:246 +0xa85
traefik  | github.com/traefik/traefik/v3/pkg/server/router.(*Manager).buildRouterHandler(0xc004cebd80, {0x8ac12e8, 0xc002b54fc0}, {0xc003e281b0, 0xd}, 0xc004cc6690)
traefik  | 	github.com/traefik/traefik/v3/pkg/server/router/router.go:202 +0x157
traefik  | github.com/traefik/traefik/v3/pkg/server/router.(*Manager).buildEntryPointHandler(0xc004cebd80, {0x8ac12e8, 0xc002b46930}, {0xc000754c50, 0x3}, 0xc002b468d0, {0xc003e28353, 0xc003e28354, 0xc003e28355, {0x7db670a, ...}})
traefik  | 	github.com/traefik/traefik/v3/pkg/server/router/router.go:152 +0x613
traefik  | github.com/traefik/traefik/v3/pkg/server/router.(*Manager).BuildHandlers(0xc004cebd80, {0x8ac1320, 0xc004cc6f50}, {0xc004b4ac80, 0x3, 0x4}, 0x0)
traefik  | 	github.com/traefik/traefik/v3/pkg/server/router/router.go:89 +0x594
traefik  | github.com/traefik/traefik/v3/pkg/server.(*RouterFactory).CreateRouters(0xc004b2c400, 0xc004cc62d0)
traefik  | 	github.com/traefik/traefik/v3/pkg/server/routerfactory.go:108 +0x225
traefik  | main.setupServer.switchRouter.func9({0xc0027295f0?, 0xc002729620?, 0xc004b8a830?, 0xc002729650?})
traefik  | 	github.com/traefik/traefik/v3/cmd/traefik/traefik.go:443 +0x52
traefik  | github.com/traefik/traefik/v3/pkg/server.(*ConfigurationWatcher).applyConfigurations(0xc004b60380, {0x8ac1320, 0xc0006d2cd0})
traefik  | 	github.com/traefik/traefik/v3/pkg/server/configurationwatcher.go:172 +0x1fb
traefik  | github.com/traefik/traefik/v3/pkg/safe.(*Pool).GoCtx.func1()
traefik  | 	github.com/traefik/traefik/v3/pkg/safe/routine.go:36 +0x54
traefik  | github.com/traefik/traefik/v3/pkg/safe.GoWithRecover.func1()
traefik  | 	github.com/traefik/traefik/v3/pkg/safe/routine.go:59 +0x4a
traefik  | created by github.com/traefik/traefik/v3/pkg/safe.GoWithRecover in goroutine 1
traefik  | 	github.com/traefik/traefik/v3/pkg/safe/routine.go:53 +0x67

traefik logs freeze after this and none of my other subdomains load either even though souin is only applied on Jellyfin proxy. Here is the static and dynamic configuration relevant snippets.

http:
  middlewares:
    http-cache:
      plugin:
        souin:
          api:
            prometheus: ""
            souin: ""
          default_cache:
            # regex:
              # exclude: '/test_exclude.*'
            ttl: 5s
            allowed_http_verbs:
              - GET
              - HEAD
              - POST
            allowed_additional_status_codes:
              - 202
              - 400
            default_cache_control: public
            headers:
              - Authorization
              - Content-Type
          log_level: debug
          urls:
            'jf.redacted.com':
              ttl: 50s
              default_cache_control: public, max-age=86400
              headers:
                - Authorization
                - Content-Type
          ykeys:
            The_First_Test:
              headers:
                Content-Type: '.+'
            The_Second_Test:
              url: 'the/second/.+'
            The_Third_Test:
            The_Fourth_Test:
          surrogate_keys:
            The_First_Test:
              headers:
                Content-Type: '.+'
            The_Second_Test:
              url: 'the/second/.+'
            The_Third_Test:
            The_Fourth_Test:

traefik configuration only contains the plugin entry under 'experimental.plugins': souin: moduleName: github.com/darkweak/souin version: v1.7.7

dynamic configuration for jellyfin:

http:
  routers:
    jellyfin:
      rule: "Host(`jf.redacted.com`)"
      entryPoints: websecure
      middlewares:
        - http-cache@file
      service: jellyfin
    http:
        services:
            jellyfin:
                loadBalancer:
                    servers:
                        - url: "http://192.168.1.2:8096"

I am aware its probably my fault somewhere in the configuration but I couldn't find an answer anywhere else and didnt know where to ask. Thanks for any help.

aroransh96 avatar Aug 24 '25 16:08 aroransh96

Hey @aroransh96, sorry for this late answer I was working on other stuff.

Here is a working example:

# Souin-configuration.yaml
http:
  routers:
    jellyfin:
      rule: "Host(`jellyfin.local`)"
      entryPoints:
        - http
      middlewares:
        - souin
      service: jellyfin

  services:
    jellyfin:
      loadBalancer:
        servers:
          - url: http://jellyfin:8096
        passHostHeader: false

  middlewares:
    souin:
      plugin:
        souin:
          default_cache:
            headers:
              - Authorization
              - Content-Type
            ttl: 5s
            default_cache_control: public
# traefik.yml
providers:
  file:
    filename: /souin-configuration.yaml
    watch: true

api:
  dashboard: true
  debug: true
  insecure: true

pilot:
  token: XXXXXXX

experimental:
  plugins:
    souin:
      moduleName: github.com/darkweak/souin
      version: v1.7.8

log:
  level: DEBUG

accessLog: {}
# compose.yaml
version: '3.4'

services:
  traefik:
    image: traefik:v3.1
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik.yml:/traefik.yml
      - ./souin-configuration.yaml:/souin-configuration.yaml
    environment:
      GOPATH: /plugins-local
    ports:
      - 80:80
      - 8080:8080

  jellyfin:
    image: jellyfin/jellyfin
    restart: unless-stopped
    user: 1000:1000
    volumes:
      - ./jellyfin/config:/config
      - ./jellyfin/media:/media
    environment:
      - JELLYFIN_PublishedServerUrl=http://jellyfin.local
    ports:
      - 8096:8096
      - 8920:8920 # optional
      - 7359:7359/udp # optional
      - 1900:1900/udp # optional

I'll try to find time to write a use case in the https://docs.souin.io about the Jellyfin setup behind Traefik with Souin as a caching system.

darkweak avatar Sep 29 '25 18:09 darkweak