Modules and existing Caddy installations

I have installed Caddy v2.2.0 via apt-get on Ubuntu 20. This doesn’t have the Redis module installed.

I am struggling to understand how to install the Redis module. From the reading I’ve done, it seems I have to build Caddy from source by first installing xcaddy? Is that correct or is there a way to somehow install this module into my existing installation?

Sorry if this is obvious or explained before.

So far I have done this:

  1. sudo apt install golang-1.14-go
  2. go get -u
  3. ~/go/bin/xcaddy build v2.2.0

This appears to have built a caddy executable which I have copied to /usr/bin. Is that correct?

The module appears to have loaded as when I list-modules I see:

This looks good but when I try and reference redis in my Caddy file (as per the docs) as so I get an error:

storage redis {
  host          ""
  port          1234
  ... etc

The error I see when running systemctl status caddy is:

/etc/caddy/Caddyfile:19: unrecognized directive: host

Line 19 is the host line in the redis config as above.

1 Like

Ok, so I think the issue might be the storage command needs ot be inside braces as well?

  storage redis {

storage isn’t a directive, it’s rather a global option:

Global options must be the first thing at the top of the Caddyfile, and as you’re figured out, must be within braces:

Be aware that if you used the apt repo, next time Caddy updates, it’ll probably overwrite your custom Caddy binary. You might want to pin to the current version to avoid that.

1 Like

Thank you for the help. How do I pin the current version? (Or should I remove Caddy via apt before installing from source?).

Also, where best to ask for help with configuring the Redis back end? I have configured my host and port using the Caddyfile but I’m still seeing connection issues when starting Caddy:

run: loading initial config: loading new config: loading storage module: loading module 'redis': 
provision dial tcp connect: connection refused isn’t configured anywhere. I appreciate it’s the Redis default but I’m telling Caddy and the Redis module to look somewhere else? I have also tried setting CADDY_CLUSTERING_REDIS_HOST and *_PORT but that doesn’t seem to make a difference (I would presume what is in the Caddy file takes precedence?).

Thanks again for your help.

Definitely on the plugin repo:

I figure it should look like this in your Caddyfile:

	storage redis {
		address redis-host:6379

		<the rest of the options>
1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.