1. The problem I’m having:
Hi everyone,
I’m having an issue when using Caddy together with Souin for caching in Ubuntu 24.04.3 LTS, Whenever I enable caching with Redis as the storage backend, Caddy panics and crashes.
I tried switching the cache storage to Dragonfly, but the same problem occurs.
I also experimented with several configuration changes, but nothing seems to have any effect.
Has anyone else experienced this issue or found a stable configuration for Souin with Redis/Dragonfly?
Any guidance or example configs would be really appreciated.
Thanks in advance!
2. Error messages and/or full log output:
```
Oct 25 08:58:37 samenc-worker-1 caddy[953102]: {"level":"error","ts":1761370117.7274086,"logger":"http.log.error.log2","msg":"error handling handler error","request":{"remote_ip":"93.119.208.56","remote_port":"58327","client_ip":"93.119.208.56","proto":"HTTP/3.0","method":"GET","host":"hrm.site.com","uri":"/index.php/offices/department-of-staff-training-and-development","headers":{"Sec-Fetch-Mode":["navigate"],"Sec-Fetch-Site":["same-site"],"Accept-Language":["en-US,en;q=0.5"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Alt-Used":["hrm.site.com"],"Upgrade-Insecure-Requests":["1"],"Cookie":["REDACTED"],"Sec-Fetch-User":["?1"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"],"Sec-Fetch-Dest":["document"],"Priority":["u=0, i"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:143.0) Gecko/20100101 Firefox/143.0"],"Referer":["https://www.site.com/"]},"tls":{"resumed":true,"version":772,"cipher_suite":4865,"proto":"h3","server_name":"hrm.site.com"}},"duration":0.000146588,"error":"{id=60g91zmvj} fileserver.(*FileServer).notFound (staticfiles.go:705): HTTP 404","first_error":{"msg":"TLS handshake not complete, remote IP cannot be verified","status":425,"err_id":"jane0atiq","err_trace":"caddyhttp.MatchRemoteIP.MatchWithError (ip_matchers.go:162)"}}
Oct 25 08:58:38 samenc-worker-1 caddy[953102]: {"level":"info","ts":1761370118.291342,"logger":"http.handlers.cache","msg":"recovered due to closed errorCacheCh chan, the request context has finished prematurely /favicon.ico"}
Oct 25 08:58:38 samenc-worker-1 caddy[953102]: {"level":"info","ts":1761370118.5642972,"logger":"http.handlers.cache","msg":"recovered due to closed errorCacheCh chan, the request context has finished prematurely /images/1404/mehr/-2147483648_-212559_2.mp4"}
Oct 25 08:58:43 samenc-worker-1 caddy[953102]: {"level":"error","ts":1761370123.670613,"logger":"http.handlers.reverse_proxy","msg":"can't switch protocols using non-Hijacker ResponseWriter","type":"struct { coraza.responseWriter; http.Pusher }"}
Oct 25 08:58:44 samenc-worker-1 caddy[953102]: {"level":"error","ts":1761370124.206436,"logger":"http.handlers.reverse_proxy","msg":"can't switch protocols using non-Hijacker ResponseWriter","type":"struct { coraza.responseWriter; http.Pusher }"}
Oct 25 08:58:45 samenc-worker-1 caddy[953102]: {"level":"info","ts":1761370125.481823,"logger":"http.handlers.cache","msg":"Reused response from concurrent request with the key GET-https-www.site.com-/"}
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: fatal error: concurrent map read and map write
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: goroutine 1794470 [running]:
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: internal/runtime/maps.fatal({0x20f7a50?, 0xc07319b0d0?})
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: runtime/panic.go:1058 +0x18
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2/modules/caddyhttp.GetVar(...)
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2@v2.10.0/modules/caddyhttp/vars.go:424
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2/modules/caddyhttp.LoggableHTTPRequest.MarshalLogObject({0xc0530697c0?, 0x45?}, {0x26abf60, 0xc02c9b0540})
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2@v2.10.0/modules/caddyhttp/marshalers.go:43 +0x133
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap/zapcore.(*jsonEncoder).AppendObject(0xc02c9b0540, {0x2677bc0, 0xc05d44b3f0})
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap@v1.27.0/zapcore/json_encoder.go:225 +0x25a
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap/zapcore.(*jsonEncoder).AddObject(0xc02c9b0540, {0x20adf66?, 0x30?}, {0x2677bc0, 0xc05d44b3f0})
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap@v1.27.0/zapcore/json_encoder.go:107 +0x3b
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap/zapcore.Field.AddTo({{0x20adf66, 0x7}, 0x2, 0x0, {0x0, 0x0}, {0x205b0c0, 0xc05d44b3f0}}, {0x26abf60, 0xc02c9b0540})
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap@v1.27.0/zapcore/field.go:121 +0xaa2
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap/zapcore.addFields(...)
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap@v1.27.0/zapcore/field.go:210
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap/zapcore.(*ioCore).With(0xc00107dc20, {0xc060459900, 0x1, 0x350?})
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap@v1.27.0/zapcore/core.go:83 +0x1a5
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2.(*filteringCore).With(0xc0008a78c0, {0xc060459900?, 0x0?, 0x1f?})
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2@v2.10.0/logging.go:593 +0x29
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap/zapcore.multiCore.With({0xc00088cd88, 0x35, 0xc053069680?}, {0xc060459900, 0x1, 0x1})
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap@v1.27.0/zapcore/tee.go:51 +0x8e
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap/zapcore.(*lazyWithCore).initOnce.func1()
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap@v1.27.0/zapcore/lazy_with.go:42 +0x30
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: sync.(*Once).doSlow(0x4773d9?, 0x80?)
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: sync/once.go:78 +0xab
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: sync.(*Once).Do(...)
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: sync/once.go:69
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap/zapcore.(*lazyWithCore).initOnce(0x419f45?)
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap@v1.27.0/zapcore/lazy_with.go:41 +0x36
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap/zapcore.(*lazyWithCore).With(0xc060459940, {0xc073cb1f40, 0x1, 0x1})
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap@v1.27.0/zapcore/lazy_with.go:47 +0x27
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap.(*Logger).With(0xc03f3ad780, {0xc073cb1f40, 0x1, 0x1})
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: go.uber.org/zap@v1.27.0/logger.go:185 +0xaf
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).ServeHTTP(0xc0016d7c08, {0x2688690, 0xc03f3ad700}, 0xc0530692c0)
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2@v2.10.0/modules/caddyhttp/server.go:387 +0x1034
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/quic-go/quic-go/http3.(*Server).handleRequest.func2(0x268bb78?, 0xc0e0e27c70?, {0x2677b60?, 0xc0016d7c08?}, 0xc09b4f6048?, 0x16?)
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/quic-go/quic-go@v0.50.1/http3/server.go:690 +0x5f
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/quic-go/quic-go/http3.(*Server).handleRequest(0xc039cd24b0, 0xc00a1a60e0, {0x269b570, 0xc0a3e9ec60}, 0xc0901cacd0, 0xc0976cf1a0)
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/quic-go/quic-go@v0.50.1/http3/server.go:691 +0xac5
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/quic-go/quic-go/http3.(*Server).handleConn.func1()
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/quic-go/quic-go@v0.50.1/http3/server.go:578 +0x5b
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: created by github.com/quic-go/quic-go/http3.(*Server).handleConn in goroutine 1790687
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/quic-go/quic-go@v0.50.1/http3/server.go:574 +0x32d
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: goroutine 1 [select (no cases), 40 minutes]:
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2/cmd.cmdRun({0x0?})
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2@v2.10.0/cmd/commandfuncs.go:291 +0xc69
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2/cmd.init.1.func2.WrapCommandFuncForCobra.1(0xc0004f8308, {0x2099eda?, 0x4?, 0x2099e96?})
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2@v2.10.0/cmd/cobra.go:141 +0x2f
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/spf13/cobra.(*Command).execute(0xc0004f8308, {0xc000578f40, 0x2, 0x2})
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/spf13/cobra@v1.9.1/command.go:1015 +0xaaa
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/spf13/cobra.(*Command).ExecuteC(0xc0002b5b08)
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/spf13/cobra@v1.9.1/command.go:1148 +0x46f
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/spf13/cobra.(*Command).Execute(...)
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/spf13/cobra@v1.9.1/command.go:1071
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2/cmd.Main()
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2@v2.10.0/cmd/main.go:72 +0x65
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: main.main()
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: caddy/main.go:16 +0xf
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: goroutine 46 [syscall, 40 minutes]:
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: os/signal.signal_recv()
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: runtime/sigqueue.go:152 +0x29
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: os/signal.loop()
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: os/signal/signal_unix.go:23 +0x13
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: created by os/signal.Notify.func1.1 in goroutine 50
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: os/signal/signal.go:152 +0x1f
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: goroutine 50 [chan receive, 40 minutes]:
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2.trapSignalsCrossPlatform.func1()
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2@v2.10.0/sigtrap.go:43 +0xde
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: created by github.com/caddyserver/caddy/v2.trapSignalsCrossPlatform in goroutine 1
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2@v2.10.0/sigtrap.go:38 +0x1a
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: goroutine 51 [chan receive, 40 minutes]:
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2.trapSignalsPosix.func1()
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2@v2.10.0/sigtrap_posix.go:39 +0xda
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: created by github.com/caddyserver/caddy/v2.trapSignalsPosix in goroutine 1
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/caddyserver/caddy/v2@v2.10.0/sigtrap_posix.go:35 +0x4b
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: goroutine 225 [chan receive]:
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/redis/rueidis.(*pipe).Do(0xc02dd02000, {0x268b9b8, 0x389cbc0}, {0xc0c0cc8180, 0x2000, 0xbf63})
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/redis/rueidis@v1.0.54/pipe.go:912 +0x56f
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/redis/rueidis.(*mux).pipeline(0xc0055a6300, {0x268b9b8, 0x389cbc0}, {0xc0c0cc8180, 0x2000, 0xbf63})
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/redis/rueidis@v1.0.54/mux.go:270 +0xf1
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/redis/rueidis.(*mux).Do(0x452308970?, {0x268b9b8?, 0x389cbc0?}, {0xc0c0cc8180, 0x2000, 0xbf63})
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/redis/rueidis@v1.0.54/mux.go:218 +0x14b
Oct 25 08:58:46 samenc-worker-1 caddy[953102]: github.com/redis/rueidis.(*singleClient).Do(0xc006c60630, {0x268b9b8, 0x389cbc0}, {0xc0c0cc8180, 0x2000, 0xbf63})
```
3. Caddy version:
v2.10.0 h1:fonubSaQKF1YANl8TXqGcn4IbIRUDdfAkpcsfI/vX5U=
4. How I installed and ran Caddy:
xcaddy build–with github.com/darkweak/souin/configurationtypes–with –with github.com/corazawaf/coraza-caddy/v2–with –with github.com/darkweak/souin/plugins/caddy–with github.com/darkweak/storages/redis/caddy–with \
d. My complete Caddy config:
http://**.site.com {
redir https://{host}{uri} permanent
}
*.site.com:443 , site.com:443 {
tls /etc/caddy/certs/77d1bf2a126b4cbcaa56875b5f88a9ea_fullchain.pem /etc/caddy/certs/77d1bf2a126b4cbcaa56875b5f88a9ea_key.pem
header {
-via
-X-Powered-By
-X-AspNet-Version
-X-AspNetMvc-Version
-X-Runtime
-X-Drupal-Cache
-X-Generator
-X-Pingback
-X-Backend-Server
-X-Varnish
-Via
-X-CDN
-X-Amz-Cf-Pop
-X-Amz-Cf-Id
-X-Cache
-X-Cache-Hits
-X-LiteSpeed-Cache
-X-Mod-Pagespeed
-X-HW
-X-Served-By
-X-Node
-X-Host
-X-Server
-X-SourceFiles
-X-Engine
-X-Envoy-Upstream-Service-Time
-X-Firefox-Spdy
-X-Frame-Options
server "SamenCloudSecurity/1.0"
}
@upgrade {
header Connection *Upgrade*
header Upgrade *websocket*
}
route {
handle @upgrade {
reverse_proxy https://10.20.30.40:443
}
@ip_access_list {
not remote_ip 0.0.0.0/0
}
handle @ip_access_list {
rewrite /var/www/default_pages/403_acl.html
file_server
}
# @geo_access_list {
# not remote_ip 0.0.0.0/0
# }
# handle @geo_access_list {
# rewrite /var/www/default_pages/403_geo.html
# file_server
# }
coraza_waf {
load_owasp_crs
directives `
SecRuleEngine On
SecAuditEngine On
SecAuditLogParts ABCDEFGHIJKZ
SecAuditLogFormat json
SecAuditLog /var/log/caddy/audit/82c09d3596a8460a819913012906baf4.log
include /etc/caddy/coraza-coreruleset/rules/crs-setup.conf
include /etc/caddy/coraza-coreruleset/rules/@owasp_crs/*.conf
# include /etc/caddy/coraza-coreruleset/rules/WAFaaS/44073a1e-65da-451f-879e-fb39eafc545d.conf
`
}
handle {
encode {
gzip 6
br 6
minimum_length 1024
match {
header Content-Type text/html
header Content-Type text/css
header Content-Type text/javascript
header Content-Type application/javascript
header Content-Type application/json
header Content-Type image/svg+xml
}
}
@cacheable {
method GET
method HEAD
}
cache @cacheable {
ttl 3600s
stale 60s
key {
hide
hash
}
cache_name test
default_cache_control
allowed_additional_status_codes 200 301 302 404
redis {
url 127.0.0.1:6379
}
storers redis
}
header {
Cache-Control "public, max-age=3600"
}
reverse_proxy {
to https://10.20.30.40:443
lb_policy round_robin
header_up Host {http.request.host}
header_up X-Forwarded-Host {http.request.host}
header_up X-Forwarded-Proto {scheme}
health_interval 60s
health_timeout 60s
transport http {
keepalive 30s
read_buffer 4MiB
write_buffer 4MiB
max_conns_per_host 10000
max_response_header 64MiB
dial_timeout 360s
response_header_timeout 360s
tls
tls_insecure_skip_verify
}
}
}
}
log {
output file /var/log/caddy/82c09d3596a8460a819913012906baf4.log {
roll_size 100mb
roll_keep 5
}
format json
level info
}
}