Caddy & cgit issues

WhitestrakeMatthew Fay10h
I’m not sure I understand why that exact setup wouldn’t work without the rewrite and a match / subdirective. Requests for static files in that setup would be going to CGI as well, right?

Yes, but the cgit.cgi application doesn’t deliver static files. For the three static files the browser needs, it makes web requests that the static file handler should manage.

The CGI plugin uses a path segment matcher.

For the request /cgit-resource/favicon.ico, first /cgit-resource/favicon.ico is checked for a match with the match subdirective, in this case /. This fails, so it lops off the last path segment and tries /cgit-resource. This fails so it tries /. In this case, it succeeds. That is, it considers /cgit-resource/favicon.ico to be a CGI application because it matches the CGI match subdirective. It then invokes cgit.cgi with PATH_INFO set to whatever got lopped off, in this case cgit-resource/favicon.ico.

It may be that a new subdirective, full_match, is warranted. This would match requests with globs as usual, but it would not attempt to match with successively shorter path segments.

1 Like