caddyserver / cache-handler

Distributed HTTP caching module for Caddy
Apache License 2.0
268 stars 22 forks source link

UNIX socket support for redis `url` #95

Closed girlbossceo closed 1 month ago

girlbossceo commented 3 months ago

Hi! I'd like to use UNIX sockets with redis and cache-handler. I don't see anything mentioning support for UNIX sockets and redis, but I tried it anyways with this syntax:

        cache {
                redis {
                        url unix//run/redis/redis.sock
                }
        }

This gives me a panic on Caddy restart/reload with:

{
    "level": "info",
    "ts": 1721688515.9645174,
    "msg": "http: panic serving @: no alive address in InitAddress\ngoroutine 8825 [running]:\nnet/http.(*conn).serve.func1()\n\tnet/http/server.go:1903 +0xbe\npanic({0x2f754c0?, 0x4d7bf90?})\n\truntime/panic.go:770 +0x132\ngithub.com/darkweak/souin/pkg/middleware.NewHTTPCacheHandler({0x39fa4c8, 0xc00036f230})\n\tgithub.com/darkweak/souin@v1.6.49/pkg/middleware/middleware.go:66 +0x8ea\ngithub.com/caddyserver/cache-handler.(*SouinCaddyMiddleware).Provision(0xc00036f208, {{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc000e0f300, 0x3, 0x4}, {0x0, 0x0, ...}, ...})\n\tgithub.com/caddyserver/cache-handler@v0.13.0/httpcache.go:248 +0x18a\ngithub.com/caddyserver/caddy/v2.Context.LoadModuleByID({{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc000e0f300, 0x3, 0x4}, {0x0, 0x0, 0x0}, ...}, ...)\n\tgithub.com/caddyserver/caddy/v2/context.go:369 +0x69b\ngithub.com/caddyserver/caddy/v2.Context.loadModuleInline({{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc004088500, 0x2, 0x2}, {0x0, 0x0, 0x0}, ...}, ...)\n\tgithub.com/caddyserver/caddy/v2/context.go:419 +0xf0\ngithub.com/caddyserver/caddy/v2.Context.LoadModule({{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc004088500, 0x2, 0x2}, {0x0, 0x0, 0x0}, ...}, ...)\n\tgithub.com/caddyserver/caddy/v2/context.go:200 +0x73e\ngithub.com/caddyserver/caddy/v2/modules/caddyhttp.(*Route).ProvisionHandlers(0xc00314faa8, {{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc004088500, 0x2, 0x2}, {0x0, 0x0, ...}, ...}, ...)\n\tgithub.com/caddyserver/caddy/v2/modules/caddyhttp/routes.go:154 +0x74\ngithub.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.ProvisionHandlers({0xc00314f508, 0x15, 0x20?}, {{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc004088500, 0x2, 0x2}, ...}, ...)\n\tgithub.com/caddyserver/caddy/v2/modules/caddyhttp/routes.go:209 +0xa6\ngithub.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Provision({0xc00314f508, 0x15, 0x25}, {{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc004088500, 0x2, 0x2}, ...})\n\tgithub.com/caddyserver/caddy/v2/modules/caddyhttp/routes.go:186 +0xbe\ngithub.com/caddyserver/caddy/v2/modules/caddyhttp.(*Subroute).Provision(0xc0040884a0, {{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc004088500, 0x2, 0x2}, {0x0, 0x0, ...}, ...})\n\tgithub.com/caddyserver/caddy/v2/modules/caddyhttp/subroute.go:58 +0x7b\ngithub.com/caddyserver/caddy/v2.Context.LoadModuleByID({{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc004088500, 0x2, 0x2}, {0x0, 0x0, 0x0}, ...}, ...)\n\tgithub.com/caddyserver/caddy/v2/context.go:369 +0x69b\ngithub.com/caddyserver/caddy/v2.Context.loadModuleInline({{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc001076430, 0x1, 0x1}, {0x0, 0x0, 0x0}, ...}, ...)\n\tgithub.com/caddyserver/caddy/v2/context.go:419 +0xf0\ngithub.com/caddyserver/caddy/v2.Context.LoadModule({{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc001076430, 0x1, 0x1}, {0x0, 0x0, 0x0}, ...}, ...)\n\tgithub.com/caddyserver/caddy/v2/context.go:200 +0x73e\ngithub.com/caddyserver/caddy/v2/modules/caddyhttp.(*Route).ProvisionHandlers(0xc002a98488, {{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc001076430, 0x1, 0x1}, {0x0, 0x0, ...}, ...}, ...)\n\tgithub.com/caddyserver/caddy/v2/modules/caddyhttp/routes.go:154 +0x74\ngithub.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.ProvisionHandlers({0xc002a98008, 0x3a, 0x11507fa?}, {{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc001076430, 0x1, 0x1}, ...}, ...)\n\tgithub.com/caddyserver/caddy/v2/modules/caddyhttp/routes.go:209 +0xa6\ngithub.com/caddyserver/caddy/v2/modules/caddyhttp.(*App).Provision(0xc0045cc0c0, {{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc001076430, 0x1, 0x1}, {0x0, 0x0, ...}, ...})\n\tgithub.com/caddyserver/caddy/v2/modules/caddyhttp/app.go:291 +0xd85\ngithub.com/caddyserver/caddy/v2.Context.LoadModuleByID({{0x39ea3f0, 0xc001039220}, 0xc002a757a0, 0xc003490000, {0xc001076430, 0x1, 0x1}, {0x0, 0x0, 0x0}, ...}, ...)\n\tgithub.com/caddyserver/caddy/v2/context.go:369 +0x69b\ngithub.com/caddyserver/caddy/v2.Context.App({{0x39ea3f0, 0xc001039220}, 0xc002a757a0, 0xc003490000, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, ...}, ...)\n\tgithub.com/caddyserver/caddy/v2/context.go:445 +0xf4\ngithub.com/caddyserver/caddy/v2.provisionContext.func3(...)\n\tgithub.com/caddyserver/caddy/v2/caddy.go:540\ngithub.com/caddyserver/caddy/v2.provisionContext(0xc00595a000?, 0x1)\n\tgithub.com/caddyserver/caddy/v2/caddy.go:545 +0x5e5\ngithub.com/caddyserver/caddy/v2.run(0x1000100?, 0x1)\n\tgithub.com/caddyserver/caddy/v2/caddy.go:400 +0x85\ngithub.com/caddyserver/caddy/v2.unsyncedDecodeAndRun({0xc005016000, 0xe43e6, 0xe6000}, 0x1)\n\tgithub.com/caddyserver/caddy/v2/caddy.go:343 +0x145\ngithub.com/caddyserver/caddy/v2.changeConfig({0x33a0442, 0x4}, {0x33a7f71, 0x7}, {0xc00557e000, 0xe43e6, 0x100000}, {0x0, 0x0}, 0x1)\n\tgithub.com/caddyserver/caddy/v2/caddy.go:234 +0x6b6\ngithub.com/caddyserver/caddy/v2.Load({0xc00557e000, 0xe43e6, 0x100000}, 0x1)\n\tgithub.com/caddyserver/caddy/v2/caddy.go:133 +0x236\ngithub.com/caddyserver/caddy/v2/caddyconfig.adminLoad.handleLoad({}, {0x39e23c0, 0xc002b1c990}, 0xc001590fc0)\n\tgithub.com/caddyserver/caddy/v2/caddyconfig/load.go:116 +0x51d\ngithub.com/caddyserver/caddy/v2.AdminHandlerFunc.ServeHTTP(0xc004415618?, {0x39e23c0?, 0xc002b1c990?}, 0xc004415580?)\n\tgithub.com/caddyserver/caddy/v2/admin.go:1299 +0x29\ngithub.com/caddyserver/caddy/v2.(*AdminConfig).newAdminHandler.func2.1({0x39e23c0, 0xc002b1c990}, 0xc001590fc0)\n\tgithub.com/caddyserver/caddy/v2/admin.go:240 +0x7b\nnet/http.HandlerFunc.ServeHTTP(0x39e2840?, {0x39e23c0?, 0xc002b1c990?}, 0x30e34a0?)\n\tnet/http/server.go:2171 +0x29\ngithub.com/caddyserver/caddy/v2.(*AdminConfig).newAdminHandler.func1.instrumentHandlerCounter.1({0x39e2840?, 0xc0026aa7e0?}, 0xc001590fc0)\n\tgithub.com/caddyserver/caddy/v2/metrics.go:47 +0x6f\nnet/http.HandlerFunc.ServeHTTP(0xc0020ce3d0?, {0x39e2840?, 0xc0026aa7e0?}, 0x148745f?)\n\tnet/http/server.go:2171 +0x29\nnet/http.(*ServeMux).ServeHTTP(0xc0020ce340?, {0x39e2840, 0xc0026aa7e0}, 0xc001590fc0)\n\tnet/http/server.go:2688 +0x1ad\ngithub.com/caddyserver/caddy/v2.adminHandler.serveHTTP({0xc0020ce340, 0x0, 0x1, {0xc000ed81c8, 0x3, 0x3}, 0x0}, {0x39e2840, 0xc0026aa7e0}, 0xc001590fc0)\n\tgithub.com/caddyserver/caddy/v2/admin.go:836 +0x55f\ngithub.com/caddyserver/caddy/v2.adminHandler.ServeHTTP({0xc0020ce340, 0x0, 0x1, {0xc000ed81c8, 0x3, 0x3}, 0x0}, {0x39e2840, 0xc0026aa7e0}, 0xc001590fc0)\n\tgithub.com/caddyserver/caddy/v2/admin.go:788 +0x7ea\nnet/http.serverHandler.ServeHTTP({0x39dcbd8?}, {0x39e2840?, 0xc0026aa7e0?}, 0x6?)\n\tnet/http/server.go:3142 +0x8e\nnet/http.(*conn).serve(0xc002130e10, {0x39ea3b8, 0xc00422c0f0})\n\tnet/http/server.go:2044 +0x5e8\ncreated by net/http.(*Server).Serve in goroutine 7716\n\tnet/http/server.go:3290 +0x4b4"
}
http: panic serving @: no alive address in InitAddress
goroutine 8825 [running]:
net/http.(*conn).serve.func1()
    net/http/server.go:1903 +0xbe
panic({0x2f754c0?, 0x4d7bf90?})
    runtime/panic.go:770 +0x132
github.com/darkweak/souin/pkg/middleware.NewHTTPCacheHandler({0x39fa4c8, 0xc00036f230})
    github.com/darkweak/souin@v1.6.49/pkg/middleware/middleware.go:66 +0x8ea
github.com/caddyserver/cache-handler.(*SouinCaddyMiddleware).Provision(0xc00036f208, {{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc000e0f300, 0x3, 0x4}, {0x0, 0x0, ...}, ...})
    github.com/caddyserver/cache-handler@v0.13.0/httpcache.go:248 +0x18a
github.com/caddyserver/caddy/v2.Context.LoadModuleByID({{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc000e0f300, 0x3, 0x4}, {0x0, 0x0, 0x0}, ...}, ...)
    github.com/caddyserver/caddy/v2/context.go:369 +0x69b
github.com/caddyserver/caddy/v2.Context.loadModuleInline({{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc004088500, 0x2, 0x2}, {0x0, 0x0, 0x0}, ...}, ...)
    github.com/caddyserver/caddy/v2/context.go:419 +0xf0
github.com/caddyserver/caddy/v2.Context.LoadModule({{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc004088500, 0x2, 0x2}, {0x0, 0x0, 0x0}, ...}, ...)
    github.com/caddyserver/caddy/v2/context.go:200 +0x73e
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Route).ProvisionHandlers(0xc00314faa8, {{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc004088500, 0x2, 0x2}, {0x0, 0x0, ...}, ...}, ...)
    github.com/caddyserver/caddy/v2/modules/caddyhttp/routes.go:154 +0x74
github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.ProvisionHandlers({0xc00314f508, 0x15, 0x20?}, {{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc004088500, 0x2, 0x2}, ...}, ...)
    github.com/caddyserver/caddy/v2/modules/caddyhttp/routes.go:209 +0xa6
github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Provision({0xc00314f508, 0x15, 0x25}, {{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc004088500, 0x2, 0x2}, ...})
    github.com/caddyserver/caddy/v2/modules/caddyhttp/routes.go:186 +0xbe
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Subroute).Provision(0xc0040884a0, {{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc004088500, 0x2, 0x2}, {0x0, 0x0, ...}, ...})
    github.com/caddyserver/caddy/v2/modules/caddyhttp/subroute.go:58 +0x7b
github.com/caddyserver/caddy/v2.Context.LoadModuleByID({{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc004088500, 0x2, 0x2}, {0x0, 0x0, 0x0}, ...}, ...)
    github.com/caddyserver/caddy/v2/context.go:369 +0x69b
github.com/caddyserver/caddy/v2.Context.loadModuleInline({{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc001076430, 0x1, 0x1}, {0x0, 0x0, 0x0}, ...}, ...)
    github.com/caddyserver/caddy/v2/context.go:419 +0xf0
github.com/caddyserver/caddy/v2.Context.LoadModule({{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc001076430, 0x1, 0x1}, {0x0, 0x0, 0x0}, ...}, ...)
    github.com/caddyserver/caddy/v2/context.go:200 +0x73e
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Route).ProvisionHandlers(0xc002a98488, {{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc001076430, 0x1, 0x1}, {0x0, 0x0, ...}, ...}, ...)
    github.com/caddyserver/caddy/v2/modules/caddyhttp/routes.go:154 +0x74
github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.ProvisionHandlers({0xc002a98008, 0x3a, 0x11507fa?}, {{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc001076430, 0x1, 0x1}, ...}, ...)
    github.com/caddyserver/caddy/v2/modules/caddyhttp/routes.go:209 +0xa6
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*App).Provision(0xc0045cc0c0, {{0x39ea3b8, 0xc0020338f0}, 0xc002a757a0, 0xc003490000, {0xc001076430, 0x1, 0x1}, {0x0, 0x0, ...}, ...})
    github.com/caddyserver/caddy/v2/modules/caddyhttp/app.go:291 +0xd85
github.com/caddyserver/caddy/v2.Context.LoadModuleByID({{0x39ea3f0, 0xc001039220}, 0xc002a757a0, 0xc003490000, {0xc001076430, 0x1, 0x1}, {0x0, 0x0, 0x0}, ...}, ...)
    github.com/caddyserver/caddy/v2/context.go:369 +0x69b
github.com/caddyserver/caddy/v2.Context.App({{0x39ea3f0, 0xc001039220}, 0xc002a757a0, 0xc003490000, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, ...}, ...)
    github.com/caddyserver/caddy/v2/context.go:445 +0xf4
github.com/caddyserver/caddy/v2.provisionContext.func3(...)
    github.com/caddyserver/caddy/v2/caddy.go:540
github.com/caddyserver/caddy/v2.provisionContext(0xc00595a000?, 0x1)
    github.com/caddyserver/caddy/v2/caddy.go:545 +0x5e5
github.com/caddyserver/caddy/v2.run(0x1000100?, 0x1)
    github.com/caddyserver/caddy/v2/caddy.go:400 +0x85
github.com/caddyserver/caddy/v2.unsyncedDecodeAndRun({0xc005016000, 0xe43e6, 0xe6000}, 0x1)
    github.com/caddyserver/caddy/v2/caddy.go:343 +0x145
github.com/caddyserver/caddy/v2.changeConfig({0x33a0442, 0x4}, {0x33a7f71, 0x7}, {0xc00557e000, 0xe43e6, 0x100000}, {0x0, 0x0}, 0x1)
    github.com/caddyserver/caddy/v2/caddy.go:234 +0x6b6
github.com/caddyserver/caddy/v2.Load({0xc00557e000, 0xe43e6, 0x100000}, 0x1)
    github.com/caddyserver/caddy/v2/caddy.go:133 +0x236
github.com/caddyserver/caddy/v2/caddyconfig.adminLoad.handleLoad({}, {0x39e23c0, 0xc002b1c990}, 0xc001590fc0)
    github.com/caddyserver/caddy/v2/caddyconfig/load.go:116 +0x51d
github.com/caddyserver/caddy/v2.AdminHandlerFunc.ServeHTTP(0xc004415618?, {0x39e23c0?, 0xc002b1c990?}, 0xc004415580?)
    github.com/caddyserver/caddy/v2/admin.go:1299 +0x29
github.com/caddyserver/caddy/v2.(*AdminConfig).newAdminHandler.func2.1({0x39e23c0, 0xc002b1c990}, 0xc001590fc0)
    github.com/caddyserver/caddy/v2/admin.go:240 +0x7b
net/http.HandlerFunc.ServeHTTP(0x39e2840?, {0x39e23c0?, 0xc002b1c990?}, 0x30e34a0?)
    net/http/server.go:2171 +0x29
github.com/caddyserver/caddy/v2.(*AdminConfig).newAdminHandler.func1.instrumentHandlerCounter.1({0x39e2840?, 0xc0026aa7e0?}, 0xc001590fc0)
    github.com/caddyserver/caddy/v2/metrics.go:47 +0x6f
net/http.HandlerFunc.ServeHTTP(0xc0020ce3d0?, {0x39e2840?, 0xc0026aa7e0?}, 0x148745f?)
    net/http/server.go:2171 +0x29
net/http.(*ServeMux).ServeHTTP(0xc0020ce340?, {0x39e2840, 0xc0026aa7e0}, 0xc001590fc0)
    net/http/server.go:2688 +0x1ad
github.com/caddyserver/caddy/v2.adminHandler.serveHTTP({0xc0020ce340, 0x0, 0x1, {0xc000ed81c8, 0x3, 0x3}, 0x0}, {0x39e2840, 0xc0026aa7e0}, 0xc001590fc0)
    github.com/caddyserver/caddy/v2/admin.go:836 +0x55f
github.com/caddyserver/caddy/v2.adminHandler.ServeHTTP({0xc0020ce340, 0x0, 0x1, {0xc000ed81c8, 0x3, 0x3}, 0x0}, {0x39e2840, 0xc0026aa7e0}, 0xc001590fc0)
    github.com/caddyserver/caddy/v2/admin.go:788 +0x7ea
net/http.serverHandler.ServeHTTP({0x39dcbd8?}, {0x39e2840?, 0xc0026aa7e0?}, 0x6?)
    net/http/server.go:3142 +0x8e
net/http.(*conn).serve(0xc002130e10, {0x39ea3b8, 0xc00422c0f0})
    net/http/server.go:2044 +0x5e8
created by net/http.(*Server).Serve in goroutine 7716
    net/http/server.go:3290 +0x4b4

I primarily want UNIX socket support for host security and confine Caddy <-> Redis to a group to access it.

Forza-tng commented 2 months ago

Unix sockets are also slightly faster due to lower latency. I'd like to see Unix socket support too.

darkweak commented 2 months ago

The redis clients used are:

For go-redis we can use the configuration (as mentioned here https://github.com/redis/go-redis/issues/3)

        cache {
                redis {
                        configuration {
                                Addr /run/redis/redis.sock
                                Network unix
                        }
                        url unix//run/redis/redis.sock
                }
        }

rueidis support the unix socket as url unix://run/redis/redis.sock

I didn't tested by myself and that based on the issues/documentation of these redis clients.

Forza-tng commented 2 months ago

The redis clients used are:

  • go-redis
  • rueidis

How do I specify to use go-redis instead of rueidis? The output from xcaddy shows both being compiled.

I tried

    cache {
        redis {
            url unix://run/redis/redis-caddy.sock
        }
    }

but this gives an error

❯ caddy -c Caddyfile-test validate
2024/08/09 09:42:28.645 INFO    using config from file  {"file": "Caddyfile-test"}
2024/08/09 09:42:28.648 INFO    adapted config to JSON  {"adapter": "caddyfile"}
2024/08/09 09:42:28.648 INFO    redirected default logger       {"from": "stderr", "to": "/var/log/caddy/test-caddy_main.log"}
panic: dial tcp: lookup tcp///run/redis/redis-caddy.sock: unknown port
goroutine 1 [running]:
github.com/darkweak/souin/pkg/middleware.NewHTTPCacheHandler({0x378f088, 0x4000654030})        github.com/darkweak/souin@v1.6.49/pkg/middleware/middleware.go:66 +0x708
github.com/caddyserver/cache-handler.(*SouinCaddyMiddleware).Provision(0x4000654008, {{0x377f3b8, 0x4000268120}, 0x400024c840, 0x40006d7620, {0x4000324600, 0x3, 0x4}, {0x0, 0x0, ...}, ...})
        github.com/caddyserver/cache-handler@v0.13.1-0.20240726111616-9b5553f04987/httpcache.go:248 +0x19c
github.com/caddyserver/caddy/v2.Context.LoadModuleByID({{0x377f3b8, 0x4000268120}, 0x400024c840, 0x40006d7620, {0x4000324600, 0x3, 0x4}, {0x0, 0x0, 0x0}, ...}, ...)
        github.com/caddyserver/caddy/v2@v2.8.4/context.go:369 +0x5f8
github.com/caddyserver/caddy/v2.Context.loadModuleInline({{0x377f3b8, 0x4000268120}, 0x400024c840, 0x40006d7620, {0x40002e03e0, 0x2, 0x2}, {0x0, 0x0, 0x0}, ...}, ...)
        github.com/caddyserver/caddy/v2@v2.8.4/context.go:419 +0x12c
github.com/caddyserver/caddy/v2.Context.LoadModule({{0x377f3b8, 0x4000268120}, 0x400024c840, 0x40006d7620, {0x40002e03e0, 0x2, 0x2}, {0x0, 0x0, 0x0}, ...}, ...)
        github.com/caddyserver/caddy/v2@v2.8.4/context.go:200 +0x608
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Route).ProvisionHandlers(0x4000872818, {{0x377f3b8, 0x4000268120}, 0x400024c840, 0x40006d7620, {0x40002e03e0, 0x2, 0x2}, {0x0, 0x0, ...}, ...}, ...)
        github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:154 +0xbc
github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.ProvisionHandlers({0x4000872788, 0x4, 0x377f3b8?}, {{0x377f3b8, 0x4000268120}, 0x400024c840, 0x40006d7620, {0x40002e03e0, 0x2, 0x2}, ...}, ...)
        github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:209 +0xc8
github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Provision({0x4000872788, 0x4, 0x4}, {{0x377f3b8, 0x4000268120}, 0x400024c840, 0x40006d7620, {0x40002e03e0, 0x2, 0x2}, ...})
        github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:186 +0xe0
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Subroute).Provision(0x40002e03a0, {{0x377f3b8, 0x4000268120}, 0x400024c840, 0x40006d7620, {0x40002e03e0, 0x2, 0x2}, {0x0,
0x0, ...}, ...})
        github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/subroute.go:58 +0xa8
github.com/caddyserver/caddy/v2.Context.LoadModuleByID({{0x377f3b8, 0x4000268120}, 0x400024c840, 0x40006d7620, {0x40002e03e0, 0x2, 0x2}, {0x0, 0x0, 0x0}, ...}, ...)
        github.com/caddyserver/caddy/v2@v2.8.4/context.go:369 +0x5f8
github.com/caddyserver/caddy/v2.Context.loadModuleInline({{0x377f3b8, 0x4000268120}, 0x400024c840, 0x40006d7620, {0x400012d0f0, 0x1, 0x1}, {0x0, 0x0, 0x0}, ...}, ...)
        github.com/caddyserver/caddy/v2@v2.8.4/context.go:419 +0x12c
github.com/caddyserver/caddy/v2.Context.LoadModule({{0x377f3b8, 0x4000268120}, 0x400024c840, 0x40006d7620, {0x400012d0f0, 0x1, 0x1}, {0x0, 0x0, 0x0}, ...}, ...)
        github.com/caddyserver/caddy/v2@v2.8.4/context.go:200 +0x608
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Route).ProvisionHandlers(0x40004fdc20, {{0x377f3b8, 0x4000268120}, 0x400024c840, 0x40006d7620, {0x400012d0f0, 0x1, 0x1}, {0x0, 0x0, ...}, ...}, ...)
        github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:154 +0xbc
github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.ProvisionHandlers({0x40004fdc20, 0x1, 0x0?}, {{0x377f3b8, 0x4000268120}, 0x400024c840, 0x40006d7620, {0x400012d0f0, 0x1, 0x1}, ...}, ...)
        github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:209 +0xc8
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*App).Provision(0x40006accc0, {{0x377f3b8, 0x4000268120}, 0x400024c840, 0x40006d7620, {0x400012d0f0, 0x1, 0x1}, {0x0, 0x0,
...}, ...})
        github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/app.go:291 +0xb38
github.com/caddyserver/caddy/v2.Context.LoadModuleByID({{0x377f3f0, 0x40005c0af0}, 0x400024c840, 0x40006d7620, {0x400012d0f0, 0x1, 0x1}, {0x0, 0x0, 0x0}, ...}, ...)
        github.com/caddyserver/caddy/v2@v2.8.4/context.go:369 +0x5f8
github.com/caddyserver/caddy/v2.Context.App({{0x377f3f0, 0x40005c0af0}, 0x400024c840, 0x40006d7620, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, ...}, ...)
        github.com/caddyserver/caddy/v2@v2.8.4/context.go:445 +0x13c
github.com/caddyserver/caddy/v2.run.func3(...)
        github.com/caddyserver/caddy/v2@v2.8.4/caddy.go:488
github.com/caddyserver/caddy/v2.run(0x40003ee780?, 0x0)
        github.com/caddyserver/caddy/v2@v2.8.4/caddy.go:493 +0x530
github.com/caddyserver/caddy/v2.Validate(0x40006d7620)
        github.com/caddyserver/caddy/v2@v2.8.4/caddy.go:690 +0x24
github.com/caddyserver/caddy/v2/cmd.cmdValidateConfig({0x0?})
        github.com/caddyserver/caddy/v2@v2.8.4/cmd/commandfuncs.go:547 +0x11c
github.com/caddyserver/caddy/v2/cmd.init.1.func8.WrapCommandFuncForCobra.1(0x4000437808, {0x3149d59?, 0x4?, 0x3149d2d?})
        github.com/caddyserver/caddy/v2@v2.8.4/cmd/cobra.go:137 +0x34
github.com/spf13/cobra.(*Command).execute(0x4000437808, {0x400014d440, 0x2, 0x2})
        github.com/spf13/cobra@v1.8.0/command.go:983 +0x840
github.com/spf13/cobra.(*Command).ExecuteC(0x4a8f560)
        github.com/spf13/cobra@v1.8.0/command.go:1115 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/caddyserver/caddy/v2/cmd.Main()
        github.com/caddyserver/caddy/v2@v2.8.4/cmd/main.go:75 +0x180
main.main()
        caddy/main.go:15 +0x1c

If iI try using Addr and Network option, Caddy complains of no live servers in InitAddress.

darkweak commented 2 months ago

@Forza-tng you can build with the master branch of Souin (that is the development repository) and use the refactored storages.

--with github.com/darkweak/souin/plugins/caddy@master --with github.com/darkweak/souin@master --with github.com/darkweak/storages/go-redis/caddy

This will use the go-redis client to connect to your redis database.

Forza-tng commented 2 months ago

Thanks. It compiles well with xcaddy, however it does not use redis even though it parses the configuration (A wrong configuration leads to an error message).

It simply just says this:

{"level":"warn","ts":1723330520.2981198,"logger":"http.handlers.cache","msg":"You're running Souin with the default storage that is not optimized and for development purpose. We recommend to use at least one of the storages from https://github.com/darkweak/storages"}
darkweak commented 2 months ago

What's your configuration @Forza-tng ?