V1 to V2: rewrite 404 errors

That’s because you’re telling Caddy to rewrite all requests to index.html if the requested path doesn’t exist as a file on disk. Since index.html does not match any of your paths on your reverse proxy, they don’t evaluate.

You’ll need to decide whether you want to serve static files or reverse proxy and then route requests accordingly.

Here’s my attempt:

:80

encode gzip
root * /Users/shared/server/components/web

handle /soc/* {
	reverse_proxy 127.0.0.1:9710
}
handle /api/* {
	reverse_proxy 127.0.0.1:9720
}
handle /fio/* {
	reverse_proxy 127.0.0.1:9730
}
handle {
	try_files {path} /index.html
	file_server browse
}

I’m just spitballing here… give it a try / derive from it if it needs tweaking.

There might be an even easier and more elegant way.

2 Likes