Can't get proxy 'without' option working

I’ve got a proxy directive on the path /api that goes to a node.js app, but I want to remove the /api part from the url. So I added the ‘without’ option to my Caddyfile as documented in https://caddyserver.com/docs/proxy but my app still receives the full url including /api.

My Caddyfile:

checklist.dev:80 {
	redir / https://checklist.dev{path}
}
checklist.dev:443 {
	tls self_signed
	header / -server
	proxy /api http://localhost:8001 {
		without /api
	}
	proxy / http://localhost:8000
}

My node.js API server routes at localhost:8001

app.use('/api/v1/checks', function(req, res) {
	console.log('1');
	res.send('1');
});
app.use('/v1/checks', function(req, res) {
	console.log('2');
	res.send('2');
});

A request to https://checklist.dev/api/v1/checks will return 1, when instead it should come back 2 (since it should match the route without the /api).

Am I missing something in my Caddyfile or is this a bug?

There’s a bug with without in 0.10
https://github.com/mholt/caddy/issues/1604

I had the same problem and downgraded back to 0.9.5 until the fix gets released.

Hi @woubuc, have you checked the issues? https://github.com/mholt/caddy/issues/1604 - is this different?

Oops, I didn’t check Github. Seems to be the same issue @matt, I’ll see if I can use the previous version for now.

Is there a way to target a specific version of Caddy when installing through getcaddy.com?

Sounds good. Just wanted to double check!

And no, not at this point. Maybe in the future, but I’m hesitant to make it easier to distribute old versions of the software.

I agree it should come with a warning, but I think it should be possible for situations like this to easily go back to a previous version for a while until a bug in the new version is fixed.

Btw, when is a bugfix release coming, to solve this?

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