Intro
Caddy is designed with a user-friendly architecture that facilitates the creation of plugins. The community actively contributes to numerous plugins, which can be explored in the list available here. These plugins enhance functionality, allowing users to, for instance, format logs or execute shell commands.
Prerequisite
- A Caddy instance (check out 01-caddy-in-docker)
Add a Plugin with CLI
Caddy is equipped with a command-line interface (CLI) that enables the seamless integration of plugins. To add a plugin, execute the following command:
Note
transform-encoder is a plugin that provides the capability to format entry logs with a distinct and customizable structure, useful for tools like fail2ban that will parse logs.
Add a Plugin for Docker
To incorporate plugins into a Docker Caddy instance, the most effective approach is to rebuild the Caddy image by including the desired plugin.
Craft a Dockerfile
based on caddy:builder
and run xcaddy
:
From my previous blog post 01-caddy-in-docker, you can edit the docker-compose.yml
file:
With these modifications, the docker-compose.yml
file will now employ the customized image caddy-custom:1.0.0
, which includes the desired plugins, in lieu of caddy:latest
.
To restart the container with the new image, just run:
If you want to rebuild the image, use:
Ressources
- Caddy’s Modules
- Photo by Kelly Sikkema on Unsplash