Run: adapting config using caddyfile: Caddyfile:3: unrecognized directive: matcher

1. My Caddy version (caddy version):

caddy2

2. How I run Caddy:

./caddy run

a. System environment:

centos 7

d. My complete Caddyfile or JSON config:

mysite.com {
tls ./fullchain.pem ./privkey.pem
matcher a {
path /apv1
}
matcher b {
path /apv2
}
rewrite match:a /apv1 /
rewrite match:b /apv2 /
reverse_proxy match:a localhost:8080

reverse_proxy match:b localhost:81
}

3. The problem I’m having:

run: adapting config using caddyfile: Caddyfile:3: unrecognized directive: matcher

A few versions ago, matcher syntax changed to:

@a {
    path /apv1
}
rewrite @a /apv1 /

Also since you’re just using a simple path matcher, you can just change your Caddyfile to something like this, I think:

mysite.com {
    tls ./fullchain.pem ./privkey.pem

    route /apv1/* {
        strip_prefix apv1/
        reverse_proxy localhost:8080
    }
    route /apv2/* {
        strip_prefix apv2/
        reverse_proxy localhost:81
    }
}

See route (Caddyfile directive) — Caddy Documentation for an example of this

2 Likes

Thanks for the quick answer!

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