Closed girlbossceo closed 1 month ago
Unix sockets are also slightly faster due to lower latency. I'd like to see Unix socket support too.
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.
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.
@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.
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"}
What's your configuration @Forza-tng ?
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:
This gives me a panic on Caddy restart/reload with:
I primarily want UNIX socket support for host security and confine Caddy <-> Redis to a group to access it.