Wildcard certificates - Logs

Hi there!

I’ve switched from Nginx to Caddy using this “template” : Common Caddyfile Patterns — Caddy Documentation and so far it’s working great :+1:

Now I would like to add some logs to this config but nothing seems to work :confused:

Where should I put the log block?

Whatever I try I have a parsing error :

Jun 26 14:53:19 cloud caddy[1998992]: Error: adapting config using caddyfile: parsing caddyfile tokens for 'handle': /etc/caddy/Caddyfile:59 - Error during parsing: parsing caddyfile tokens for 'route': /etc/caddy/Caddyfile:57 - Error during parsing: parsing caddyfile tokens for 'reverse_proxy': /etc/caddy/Caddyfile:50 - Error during parsing: unrecognized subdirective log

Thank you!

I think you forgot to share your config :sweat_smile:

But basically, you put the log directive where all other directives go: directly inside a site block.

I’d recommend reading this page, it is very helpful:

right :sweat_smile:

http://example.com, https://example.com {
  redir https://www.{host}{uri}
}

*.example.com {
  tls {
    dns ovh {
    }
  }

  @www host www.example.com
  handle @www {
    root * /data/apps/foo/public
    encode gzip
    php_fastcgi unix//data/apps/foo/shared/sockets/php-fpm.sock
    file_server
  }

  @seafile host seafile.example.com
  handle @seafile {
    route /onlyofficeds/* {
      uri strip_prefix /onlyofficeds
      reverse_proxy {
        to http://localhost:8067
        header_up X-Forwarded-Host {host}/onlyofficeds
      }
    }
    reverse_proxy http://localhost:8066
  }
}

So just put it inside your site block, e.g.:

*.example.com {
    log
    ...
1 Like

Indeed :slight_smile:
Thank you!

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