Skip to main content

Caddy

Caddy can be configured automatically using Devbox's built in Caddy plugin. This plugin will activate automatically when you install Caddy using devbox add caddy

Example Repo

Open In Devspace

Adding Caddy to your Shell

Run devbox add caddy, or add the following to your devbox.json

  "packages": [
"caddy@latest"
]

This will install the latest version of Caddy. You can find other installable versions of Caddy by running devbox search caddy. You can also view the available versions on Nixhub

Caddy Plugin Details

The Caddy plugin will automatically create the following configuration when you install Caddy with devbox add

Services

  • caddy

Use devbox services start|stop caddy to start and stop httpd in the background

Helper Files

The following helper files will be created in your project directory:

  • {PROJECT_DIR}/devbox.d/caddy/Caddyfile
  • {PROJECT_DIR}/devbox.d/web/index.html

Note that by default, Caddy is configured with ./devbox.d/web as the root. To change this, you should modify the default ./devbox.d/caddy/Caddyfile or change the CADDY_ROOT_DIR environment variable

Environment Variables

* CADDY_CONFIG={PROJECT_DIR}/devbox.d/caddy/Caddyfile
* CADDY_LOG_DIR={PROJECT_DIR}/.devbox/virtenv/caddy/log
* CADDY_ROOT_DIR={PROJECT_DIR}/devbox.d/web

Notes

You can customize the config used by the caddy service by modifying the Caddyfile in devbox.d/caddy, or by changing the CADDY_CONFIG environment variable to point to a custom config. The custom config must be either JSON or Caddyfile format.

Disabling the Caddy Plugin

You can disable the Caddy plugin by running devbox add caddy --disable-plugin, or by setting the disable_plugin field in your devbox.json:

{
"packages": {
"caddy": {
"version": "latest",
"disable_plugin": true
}
},
}