Caddy
Introduction
Caddy is running with a resumed configuration. TheĀ --resume
flag means Caddy is using the last known good configuration, which is stored internally as a JSON object. This configuration is auto-saved when Caddy is running and can be reused on restarts or reloads. It does not necessarily rely on a Caddyfile.
Though, you can use a Caddyfile to define your server configuration which can be adapted to JSON configuration. The Caddyfile allows for more straightforward definitions for things like global HTTPS enforcement, after which you could translate it into a JSON configuration using caddy adapt
if needed.
1. Examine the Current Configuration:
You can query Caddy's API to see the current JSON configuration:
curl http://localhost:2019/config/
The JSON configuration retrieved from http://localhost:2019/config/
is the active runtime configuration held in memory by the Caddy server. It is not stored in a file by default, which is why querying the API is often the easiest way to view the current configuration.
2. Export the Current Configuration:
If you want to save the current JSON configuration to a file, you can redirect the output of the curl command:
curl http://localhost:2019/config/ > caddy_config.json
3. Modify Configuration
Fetch the current JSON configuration from the Caddy API, so you know what needs to be changed:
You can either modify the JSON configuration directly through the API:
curl -X POST "http://localhost:2019/load" \
-H "Content-Type: application/json" \
--data @current_caddy_config.json
After you've applied your changes, you should verify that they have taken effect. You can again query Caddy's API to get the current configuration and check if it reflects your modifications:
curl http://localhost:2019/config/