V2: Multiple routes, with a default catch-all

New spelling error on my part, I think. I’m trying to set up a reverse_proxy for all urls, except for one given path, which will use file_browser.

If I comment out the reverse_proxy part in the Caddyfile, the file_browser works. (I have created the folder, and I can see the content.)

But when reverse_proxy is uncommented, all requests go to the reverse proxy.

1. Caddy version (caddy version):

v2.0.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=

2. How I run Caddy:

a. System environment:

Windows

b. Command:

caddy.exe run

c. Service/unit/compose file:

n/a

d. My complete Caddyfile or JSON config:

# Caddy v2
{
    debug
}

http://localhost:4200 {
	
	log {
		output stdout 
	}

	file_server  /test/* {
		browse
	}

	reverse_proxy https://sense-demo.qlik.com:443 { 
		header_up Host sense-demo.qlik.com
		header_up X-MyHeader "Test"
		
		transport http {
			tls_insecure_skip_verify 
		}
	}

}


3. The problem I’m having:

When reverse_proxy is present, I cannot browse the files on http://localhost:4200/test/.

4. Error messages and/or full log output:

5. What I already tried:

I’ve tried reverse_proxy /*, reverse_proxy *, reverse_proxy /, and reverse_proxy .

I’v tried putting file_browser after and before reverse_proxy.

No avail. Can someone spot my new typo, please? :open_mouth:

6. Links to relevant resources:

Caddy has a predefined order in which handlers are sorted.

You’ll see that reverse_proxy comes before file_server. That means that what you have to do is exclude reverse_proxy from being matched so that file_server can be reached. You can do this with a not matcher. For example:

root * /path/to/site/root

@notStatic {
	not path /static/*
}
reverse_proxy @notStatic https://sense-demo.qlik.com:443

file_server browse
1 Like

Ah. So that’s the reason. Thank you! That works! :slight_smile:

This exact situation (almost) is explained here: route (Caddyfile directive) — Caddy Documentation

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