Unable to utilise xCaddy with Souin and Redis

1. The problem I’m having:

I am trying to utilise xCaddy with Redis and Souin, I can get go-redis to work, but NOT Redis storage provider.

2. Error messages and/or full log output:

2025/02/19 20:40:46.514 ERROR   http.handlers.cache     Error during Redis init, did you include the Redis storage (--with github.com/darkweak/storages/redis/caddy or github.com/darkweak/storages/go-redis/caddy)

3. Caddy version:

caddy:2.9.1-builder-alpine

4. How I installed and ran Caddy:

a. System environment:

Docker in AWS

b. Command:

Supervisor

c. Service/unit/compose file:

# syntax=docker/dockerfile:1.4

# Build Go optimizer service
FROM golang:1.21-alpine AS go-builder
WORKDIR /go/src/optimizer

# Install build dependencies
RUN apk add --no-cache \
    gcc \
    musl-dev \
    vips-dev \
    build-base \
    && rm -rf /var/cache/apk/*

# Copy and build the Go service
COPY optimizer/main.go ./

# Initialize Go module and build with better error handling
RUN set -ex && \
    go mod init optimizer && \
    go get github.com/gofiber/fiber/v2@latest && \
    go get github.com/h2non/bimg@latest && \
    go get github.com/valyala/fasthttp@latest && \
    go mod tidy && \
    CGO_ENABLED=1 GOOS=linux go build -v -o /go/bin/optimizer

# Final stage with Caddy
FROM caddy:2.9.1-builder-alpine AS builder

RUN xcaddy build \
    --with github.com/darkweak/souin/plugins/caddy \
    --with github.com/darkweak/storages/redis/caddy


FROM caddy:2.9.1-builder-alpine

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

# Install runtime dependencies and supervisord
RUN apk add --no-cache \
    vips \
    supervisor \
    && rm -rf /var/cache/apk/*

# Copy Go binary
COPY --from=go-builder /go/bin/optimizer /usr/local/bin/

# Copy config files
COPY supervisord.conf /etc/supervisor/supervisord.conf

# Create directories
RUN mkdir -p /etc/caddy

# Use EXPOSE for documentation
EXPOSE 80 443 3001

# Use supervisor as entrypoint
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]

d. My complete Caddy config:

{
    # Certificate storage configuration
    storage file_system /etc/caddy/certificates

    # Server protocols and keepalive settings
    servers {
        protocols h1 h2 h2c h3
        keepalive_interval 60s
    }

    # Cache configuration
    cache {
        ttl 2h
        redis {
            url 4b96omey8.test.cloud:6385
            Username default
            Password 
        }
        cache_name Caddy
        default_cache_control "public, max-age=7200"
        allowed_http_verbs GET HEAD
    }
}

# Encoding snippet
(encoding) {
    encode zstd
}

# TLS configuration snippet
(tls) {
    tls {
        on_demand
        protocols tls1.3
    }
}

# Headers snippet
(headers) {
    header Cache-Control "max-age=3600"
    header -Server
}

# Import site configurations
import sites/*

5. Links to relevant resources:

If so, how do you even configure Redis with a Username, and Password?

redis {
   configuration {
    
  }
}

or just

redis {

}
  • Further adding onto this, the only way I can get Caddy to not throw a error is via this configuration:
    cache {
        ttl 2h
        redis {
            configuration {
               InitAddress 4b96omey8.example.cloud:6385
               Username default
               Password mypassword
            }
        }
        cache_name Caddy
        default_cache_control "public, max-age=7200"
        allowed_http_verbs GET HEAD
    }

However, I still get:

2025/02/19 20:55:14.568 WARN http.handlers.cache 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 GitHub - darkweak/storages: Souin's storages

And I still see

Caddy; hit; ttl=7175; key=GET-https-my-domain.io-/; detail=DEFAULT

not

Caddy; hit; ttl=7175; key=GET-https-my-domain.io-/; detail=REDIS

  • Further context, when building the Docker image, yes Redis is installed properly:

[app builder 2/2] RUN xcaddy build --with github.com/darkweak/souin/plugins/caddy --with github.com/darkweak/storages/redis/caddy

If I replace redis with go-redis, it works fine, go-redis works great.

I’ve confirmed with others using Redis, it is broken, needs to be fixed.