Published on

Caddy: Modules and Plugins

Authors

Welcome back! This week we're taking a look at Caddy modules. Off the bat, it's important to note that Caddy comes with some modules pre-installed (called 'standard' modules): Here is the full list!

Famous standard modules

  • reverse_proxy
  • file_server
  • metrics
  • http_redirect

Standard modules can be used with the default version of Caddy, but let's say that you want to use Amazon S3 as a shared certificate store for a cluster of Caddy servers. You'll need to add the caddy.fs.s3 module.

Using xcaddy to build Caddy with non-standard Modules

No problem. Download the xcaddy binary, and run it with: $> xcaddy build --with github.com/ss098/certmagic-s3

Xcaddy will automatically fetch the required plugin from GitHub during the build process. Want to add more than one module?

$> xcaddy build --with github.com/ss098/certmagic-s3 --with github.com/firecow/caddy-elastic-encoder --with github.com/mholt/caddy-dynamicdns --with github.com/zhangjiayin/caddy-geoip2

The xcaddy command will automatically output to a binary called xcaddy. You can change the default output file with the --output flag:

$>xcaddy build --with github.com/ss098/certmagic-s3 --output clustercaddy

From there, you can run your new binary however you'd like, e.g.: $>caddy run --config /etc/caddy/Caddyfile

Using the S3 Module for Shared Storage (for example)

You might deploy a handful of Caddy servers which all share the same application (uhhh, like a CDN). Caddy makes this easy with the storage.s3 module:

/etc/caddy/Caddyfile
# Global Config
{
    storage s3 {
        host "Host"
        bucket "Bucket"
        access_id "Access ID"
        secret_key "Secret Key"
        prefix "ssl"
        insecure false #disables SSL if true
    }
}

Looking at the s3 storage module github repo, we can read more about how to configure and use it. If all is right, you should be able to reload the configuration and Caddy will automatically begin using the new S3 storage for certificates and HTTP challenge information.

What other modules are there?

You can view the full list of Caddy modules here.

At Skip2, we use the following modules for our CDN infrastructure:

Wrapping up

I hope you enjoyed learning the tip of the iceberg about Caddy modules. There is so much more to learn and so many modules to make serving your web application easier. Next week, we're going to delve into load balancing!

Want to learn more about Caddy?

Visit their official website at caddyserver.com Read through the docs at caddyserver.com/docs If you use it, sponsor the project (we do!) caddyserver.com/sponsor

This post is one of a series of tutorials about Caddy Server. You can view all relevant posts here.

Learn about Skip2

Sign up for our newsletter

Get Started