Caddy 反向代理,优先文件,然后 reverse_proxy

Caddy reverse proxy, prioritize files, then reverse_proxy

我在使用 Caddy v2 时遇到了问题,而在 v1 中我从来没有遇到过这样的问题

我想优先考虑:

file_server if started with /upload/*
reverse_proxy to 127.0.0.1:9090 if started with /api/*
else reverse_proxy to 127.0.0.1:3000

但似乎我无法使用 v2 使其正常工作,我已经尝试了很多(使用匹配器,更改端口,因为 127.0.0.1 总是 404 但 localhost 没有,等等)但似乎 127.0.0.1:3000 总是优先而不是 file_server 即使文件存在,因为它有通配符?

{
        debug
        auto_https off
        log {
                output stdout
                level DEBUG
        }
        local_certs
}

127.0.0.1:80, localhost:80 {
        root ./svelte/dist
        file_server /upload/* browse
        reverse_proxy /api/* 127.0.0.1:9090
        reverse_proxy * 127.0.0.1:3000
}

没关系,得到答案 https://caddy.community/t/v2-hard-to-make-it-right/13394/2

127.0.0.1, 127.0.0.1:80, localhost, localhost:80 {
        handle /upload/* {
                root ./svelte/dist
                file_server browse
        }

        handle /api/* {
                reverse_proxy 127.0.0.1:9090
        }

        handle {
                reverse_proxy 127.0.0.1:3000
        }
}