Caddyfile config for reverse proxy using domain subfolder

Which version, specifically? It matters (you might be on an older version with bugs, etc).

Run docker-compose exec caddy caddy version to find out.

You’re better off using subdomains for each service instead. Proxying to subpaths is tricky, and often not possible depending on how the upstream app is implemented or configured. Just make sure *.labahouse.ddns.net also resolves to your server’s IP address as well.

But your Caddyfile has three issues:

First, you need to make sure you have a space the site address and the {, otherwise Caddy will parse the { as being part of the address, which doesn’t make sense.

Second, path matching in Caddy is exact, so if you try to use a path matcher like /mv, it will only match requests to exactly /mv and not /mv/foo. You need to use a * to tell Caddy to match more, i.e. /mv*. But in general, I strongly suggest not using path matchers in the site address, and to instead use the handle directive in a single site block if you need to make separate routes. For example:

https://labahouse.ddns.net {
	handle /mv* {
		reverse_proxy 10.0.0.40:80
	}

	handle {
		respond "Saluti da casamia"
	}
}

Third, Caddy doesn’t support paths in the reverse_proxy upstream address, because that implies a simultaneous rewrite. If you need to rewrite the request path, then use the rewrite directive to perform it before proxying.