Trusted_proxies directive not working

1. Output of caddy version:

latest

2. How I run Caddy:

docker

a. System environment:

arch linux

b. Command:

docker compose up

c. Service/unit/compose file:

version: "3.9"

services:
  caddy:
    build: .
    image: caddy
    container_name: caddy
    ports:
      - 80:80
      - 443:443
    networks:
      - caddy
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./data:/data
      - ./config:/config
      - ./Caddyfile.d:/etc/caddy/Caddyfile.d
    restart: unless-stopped

networks:
  caddy:
    name: caddy

d. My complete Caddy config:

{
    email admin@domain.xyz
    acme_dns cloudflare REDACTED-
}

(genericheaders) {
    header {
        Strict-Transport-Security "max-age=31536000; includesubdomains; preload"
    }
}

(trusted_proxy_list) {
       trusted_proxies 10.0.0.0/8 172.16.0.0/16 192.168.0.0/16 fc00::/7
}

(encoding) {
  encode zstd gzip
}

(authelia) {
    forward_auth authelia:9091 {
            uri /api/verify?rd=https://auth.domain.xyz/
            copy_headers Remote-User Remote-Groups Remote-Name Remote-Email

            ## This import needs to be included if you're relying on a trusted proxies configuration.
            import trusted_proxy_list
    }
}

import /etc/caddy/Caddyfile.d/*.Caddyfile

3. The problem I’m having:

It says that the directive trusted_proxies is wrong. But I am copying that form the authelia docs:

4. Error messages and/or full log output:

caddy  | {"level":"info","ts":1666774736.5764437,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
caddy  | Error: adapting config using caddyfile: /etc/caddy/Caddyfile:13: unrecognized directive: trusted_proxies
caddy exited with code 1

Hi @r3nor,

I wasn’t able to replicate this issue with the current version of Caddy. Please upgrade and ensure you’re on the latest release.

whitestrake in ~ at merlin
➜ caddy list-modules --skip-standard
dns.providers.cloudflare

  Non-standard modules: 1

  Unknown modules: 0
whitestrake in ~ at merlin
➜ caddy version
v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=
whitestrake in ~ at merlin
➜ cat Caddyfile
{
    email admin@domain.xyz
    acme_dns cloudflare REDACTED-
}

(genericheaders) {
    header {
        Strict-Transport-Security "max-age=31536000; includesubdomains; preload"
    }
}

(trusted_proxy_list) {
       trusted_proxies 10.0.0.0/8 172.16.0.0/16 192.168.0.0/16 fc00::/7
}

(encoding) {
  encode zstd gzip
}

(authelia) {
    forward_auth authelia:9091 {
            uri /api/verify?rd=https://auth.domain.xyz/
            copy_headers Remote-User Remote-Groups Remote-Name Remote-Email

            ## This import needs to be included if you're relying on a trusted proxies configuration.
            import trusted_proxy_list
    }
}

import /etc/caddy/Caddyfile.d/*.Caddyfile
whitestrake in ~ at merlin
➜ caddy validate
2022/10/27 05:13:43.763	INFO	using adjacent Caddyfile
2022/10/27 05:13:43.764	WARN	No files matching import glob pattern	{"pattern": "/etc/caddy/Caddyfile.d/*.Caddyfile"}
2022/10/27 05:13:43.765	WARN	Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies	{"adapter": "caddyfile", "file": "Caddyfile", "line": 2}
Valid configuration
2 Likes

This topic was automatically closed after 30 days. New replies are no longer allowed.