Caddy and cloudflare

1. The problem I’m having:

caddy validate fails with unrecognized global option: trusted_proxies even on a minimal Caddyfile.

  • Minimal Caddyfile that Fails:
    {
    trusted_proxies {
    source cloudflare
    }
    }

http://localhost:8080 {
respond “Test OK”
}

2. Error messages and/or full log output:

Error: adapting config using caddyfile: /etc/caddy/Caddyfile:2: unrecognized global option: trusted_proxies

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

3. Caddy version:

Caddy Version: v2.9.1

4. How I installed and ran Caddy:

apt get install

a. System environment:

Ubuntu 20.04 LTS

b. Command:

caddy validate --config /etc/caddy/Caddyfile2025/04/11 23:28:18.502 INFO    using config from file  {"file": "/etc/caddy/Caddyfile"}
Error: adapting config using caddyfile: /etc/caddy/Caddyfile:2: unrecognized global option: trusted_proxies
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

c. Service/unit/compose file:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

d. My complete Caddy config:

{
    trusted_proxies {
        source cloudflare
    }
}

http://localhost:8080 {
    respond "Test OK"
}

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

5. Links to relevant resources:

Currently, only the static IP source module is included with the standard distribution of Caddy, but this can be extended with plugins to maintain a dynamic list of IP ranges.

1 Like

According to the official Caddy documentation for v2.9.1 (Global options (Caddyfile) — Caddy Documentation), the cloudflare source is built-in to the standard Caddy distribution.
More over the error is: unrecognized global option: trusted_proxies.
Caddy isn’t recognizing the directive name trusted_proxies itself when placed in the global options block

Where’s servers?

2 Likes

That’s not true. Where does the doc say this? The documentation page says:

Currently, only the static IP source module is included with the standard distribution of Caddy

2 Likes

This placement is wrong

It goes inside servers. Refer to the example in the doc page.

2 Likes

Problem solved. It works with static IP source module. Thank you

1 Like