Reverse proxy to a localhost isn't behaving as I expect

Directives are not executed per the order they appear in in the Caddyfile, rather per a pre-defined order. See the default order here:

The order can be overriden using the route directive, which obeys the order directives appear in. Another trick is to use the handle directive to create mutually-exclusive handler blocks.

The crux of the matter is the question of whether you want route-first approach or behavior-first. Matt discusses the differences, pros, and cons in this Wiki post.

1 Like