Getting "unrecognized global option: admin caddy"

Edit: the solution was simply to remove the listen which I copied from elsewhere. The correct configuration is simply:

{
        admin 0.0.0.0:2019
}

being put on top of everything else.
So problem solved.

1. Caddy version (v2.1.0):

2. How I run Caddy:

I’m running Caddy part of a Docker container with the appropriate ports bindings. Everything works fine without the admin directive which is intended to expose Admin API to host

a. System environment:

Ubuntu 22.
Docker 20.10.

b. Command:

Just running docker

c. Service/unit/compose file:

version: '3.7'
services:
  classified-ads:
    container_name: classified-ads
    depends_on:
      - mongodb-service
      - redis-service
      - caddy-service
    ports:
      - 3000:3000
    build:
      context: ./


  mongo:
      container_name: mongodb-service
      image: mongo
      volumes:
        - ./host-db/data:/data/db
        - ./bootstrap/init-db.js:/docker-entrypoint-initdb.d/init-db.js:ro
      ports:
        - '27017:27017'

  redis:
      container_name: redis-service
      image: redis:7.0.0-alpine
      # restart: unless-stopped
      ports:
        - '6379:6379'
      volumes: 
        - ./host-db/data:/data

  caddy:
      container_name: caddy-service
      image: caddy/caddy:2.5.1-alpine
      restart: unless-stopped
      ports:
        - "80:80"
        - "443:443"
		- "2019:2019"
      volumes:
        - ./referral-spam.caddy:/etc/caddy/referral-spam.caddy
        - ./Caddyfile:/etc/caddy/Caddyfile
        - './:/srv'
        - caddy_data:/data
        - caddy_config:/config

volumes:
  caddy_data:
  caddy_config:

d. My complete Caddyfile or JSON config:

{
        admin {
                listen 0.0.0.0:2019
        }
}

domain.ip-188-165-209.eu {
        # import ./referral-spam.caddy
        reverse_proxy classified-ads:3000
}

3. The problem I’m having:

4. Error messages and/or full log output:

caddy-service | {“level”:“info”,“ts”:1657559685.4484925,“msg”:“using provided configuration”,“config_file”:“/etc/caddy/Caddyfile”,“config_adapter”:“caddyfile”}
caddy-service | run: adapting config using caddyfile: parsing caddyfile tokens for ‘admin’: /etc/caddy/Caddyfile:3 - Error during parsing: unrecognized parameter ‘listen’
caddy-service exited with code 1

5. What I already tried:

Other variations like:
{
admin 0.0.0.0:2019
}

Thanks a lot ! The HTTPS out of the box is a blessing for me !!

1 Like

That’s a really old version. Please upgrade to v2.5.1!

Yep, that’s correct! Glad you figured it out.

1 Like

It is one of the solutions in my development experience that really made me happy and fulfilled!!! What a gift to us developers with limited networking knowledge. I cannot thank enough!! My site is up although in beta I’m so happy it went easy

2 Likes

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