Unknown field split_path using adjacent Caddyfile

I just updated to Caddy 2 Stable from RC3. When I try caddy reload, it throws the following error:

2020/05/07 08:02:29.237 INFO    using adjacent Caddyfile
reload: sending configuration to instance: caddy responded with error: HTTP 400: {"error":"loading config: loading new config: loading http app module: provision http: server srv0: setting up route handlers: route 0: loading handler modules: position 0: loading module 'subroute': provision http.handlers.subroute: setting up subroutes: route 4: loading matcher modules: module name 'file': decoding module config: http.matchers.file: json: unknown field \"split_path\""}

The following Code on Caddy file was working fine on RC3. But, it is showing above error after updating to v2 stable release.

example1.com, www.example1.com, cdn.example1.com {
tls /etc/letsencrypt/live/example1.com/fullchain.pem /etc/letsencrypt/live/example1.com/privkey.pem
root * /var/www/html/example2
php_fastcgi unix//var/opt/remi/php74/run/php-fpm/www.sock
encode gzip
file_server
header Strict-Transport-Security max-age=7884000
@static {
file 
path *.ico *.css *.js *.gif *.jpg *.jpeg *.png *.svg *.woff *.woff2
}
header @static Cache-Control max-age=7884000
log {
output file /var/log/caddy/example1.log
format console
}
}
example2.com, www.example2.com, cdn.example2.com {
tls /etc/letsencrypt/live/example2.com/fullchain.pem /etc/letsencrypt/live/example2.com/privkey.pem
root * /var/www/html/example2
php_fastcgi unix//var/opt/remi/php74/run/php-fpm/www.sock
encode gzip
file_server
header Strict-Transport-Security max-age=7884000
@static {
file 
path *.ico *.css *.js *.gif *.jpg *.jpeg *.png *.svg *.woff *.woff2
}
header @static Cache-Control max-age=7884000
log {
output file /var/log/caddy/example2.log
format console
}
}

Please help me with this.

Can you please mark your error and your configs as code, so indentation is preserved and it’s easier to read?

As for split_path, I don’t see it mentioned anywhere in your config…

To elaborate a bit on @piranha’s advice, you can do that by surrounding your config in triple backticks (```).

You can alternately just paste it all, select it, and then hit the “Preformatted text” button in the post editor:

Screen Shot 2020-05-07 at 7.04.51 pm

This will make it much easier to help you.

oh okay but I am in need of solution please.

Man, you won’t get much help without any real effort from your side. It’s just tiring to read plain text with no indentation, plus I have feeling that you didn’t post whole config.

I think you need to read this.

1 Like

Okay done that! n Yes that’s the whole config man.

It is really like that, with no identation? I think if you had it like that it would be easier to edit and read:

example1.com, www.example1.com, cdn.example1.com {
  tls /etc/letsencrypt/live/example1.com/fullchain.pem /etc/letsencrypt/live/example1.com/privkey.pem
  root * /var/www/html/example2
  php_fastcgi unix//var/opt/remi/php74/run/php-fpm/www.sock
  encode gzip
  file_server
  header Strict-Transport-Security max-age=7884000
  @static {
    file 
    path *.ico *.css *.js *.gif *.jpg *.jpeg *.png *.svg *.woff *.woff2
  }
  header @static Cache-Control max-age=7884000
  log {
    output file /var/log/caddy/example1.log
    format console
  }
}

example2.com, www.example2.com, cdn.example2.com {
  tls /etc/letsencrypt/live/example2.com/fullchain.pem /etc/letsencrypt/live/example2.com/privkey.pem
  root * /var/www/html/example2
  php_fastcgi unix//var/opt/remi/php74/run/php-fpm/www.sock
  encode gzip
  file_server
  header Strict-Transport-Security max-age=7884000
  @static {
    file 
    path *.ico *.css *.js *.gif *.jpg *.jpeg *.png *.svg *.woff *.woff2
  }
  header @static Cache-Control max-age=7884000
  log {
    output file /var/log/caddy/example2.log
    format console
  }
}

I don’t see anything about split_path here, maybe someone more experienced can comment on that.

@piranha do you think that’s the bug on Caddy itself? @Whitestrake any clue?

Okay I got the answer on Github. What I need to do after update is:

caddy stop
caddy start

& then
caddy reload

Works.

1 Like

i’m still trying to figure out why you’re using custom certificates while caddy is handling that already for you

  • format console is default you can delete this line if you want.
  • encode zstd gzip will compress better.

For reference, it was answered here:

1 Like

@tweeniev2 I removed format console and now using encode zstd gzip.

I am using custom certificate because Dovecot and Postfix are also using those certificates. So, to make same certificate work for both email and website, I am using custom certificate. In that case, I have not removed certbot.

On the other hand, that cdn . example . com is working on Cloudfront with that certificate. And then, I am using Cloudfront directly on my apex domain.

I may try something else out soon after I get more and more familiar with Caddy. Right now I am a starter!

i am doing same. my email server got different certificate and website got different.

1 Like

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