Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/docs/markdown/caddyfile/concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -821,4 +821,16 @@ For example, if you have the [`caddy-dns/cloudflare` plugin <img src="/old/resou
}
```

Environment variables are convenient, but sensitive values in a process environment can be exposed by process inspection, child process inheritance, logs, crash dumps, or platform diagnostics.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line feels weird, because it's like "well everything you just read? forget about it because this and this and that." It's strange to have something criticize the use of env vars, in the env vars section of the docs (I don't disagree with the content though, it's true).

I don't have a specific answer to this, but it needs some rethinking of where exactly this fits into the docs.


For secrets, prefer your platform's secret management mechanism when available. If the secret is provided as a file, you can use the [global `{file.*}` placeholder](/docs/conventions#placeholders) in config fields which support placeholders:

```caddy
{
acme_dns cloudflare {file./run/secrets/cloudflare_api_token}
}
```

This does not make the secret inaccessible to Caddy; the Caddy process still needs permission to read the file. It avoids placing the secret value in the process-wide environment.

If you're running Caddy as a systemd service, see [these instructions](/docs/running#overrides) for setting service overrides to define your environment variables.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is still talking about env vars, so it's weird that the {file.*} stuff is cutting right in the middle of it. Needs reorganizing.

2 changes: 1 addition & 1 deletion src/docs/markdown/conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ The following placeholders are always available (global):
Placeholder | Description
------------|-------------
`{env.*}` | Environment variable; example: `{env.HOME}`
`{file.*}` | Contents from a file; example: `{file./path/to/secret.txt}`
`{file.*}` | Contents from a file, useful when a secret is supplied as a file; example: `{file./path/to/secret.txt}`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change is necessary, it's redundant - the example has secret.txt, pretty self explanatory.

I want to be careful on the length of the description mainly for visual reasons, line wrapping etc.

`{system.hostname}` | The system's local hostname
`{system.slash}` | The system's filepath separator
`{system.os}` | The system's OS
Expand Down