Wildcard proxy with file_server under specific folder

1. The problem I’m having:

I’m using an API server behind Caddy. The API server produces files on request which I want to serve via Caddy (file_server).

I’m using a wildcard * for the proxy and /store/* for file_server.

Even though the file_server matcher is longer and should be preferred, the proxy wildcard matcher always takes precedence.

I verified the file_server matcher working by disabling the proxy - in that case it works as expected.

2. Error messages and/or full log output:

No error output, I just always end up at the proxy server even if a path starting with /store/<foobar> is used.

3. Caddy version:

2.6.2

4. How I installed and ran Caddy:

sudo apt install caddy

a. System environment:

# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux trixie/sid"
NAME="Debian GNU/Linux"
VERSION_CODENAME=trixie
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

b. Command:

systemctl start caddy

c. Service/unit/compose file:

Debian default, I’m sure they did a good job.

d. My complete Caddy config:

:80 {
	root * /srv/
	file_server /store/*
	reverse_proxy localhost:8001
}

5. Links to relevant resources:

n/a

I am still learning, but what I see is you are trying to do two different things with the same requests.

I think it is either or, you either serve the request as a file server OR to pass the request to a backend via the reverse proxy.

Again I am very new to this, but that is what I see.

Brad

If my understanding is right, you want something similar to X-Accel-Redirect pattern described here:

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