Using Caddy as a reverse proxy with multiple subdirectories and rewrites

FWIW, I’d write it like this (for mutual exclusivity)

psono.beeswax.eu {
	handle_path /server* {
		reverse_proxy localhost:10100
	}

	handle /portal* {
		reverse_proxy localhost:10102
	}

	handle {
		reverse_proxy localhost:10101
	}
}

I think it’s easier to read – you can clearly see top-down how a request will be handled. The handle without a matcher will catch any request that wasn’t otherwise matched by the previous 2 handles.

2 Likes