Hi, I’m new to Caddy and I use the cgi module. I’d like to serve all file of my vhost through the CGI excepted /cgit.css /custom.css /logo.svg /favicon.svg /robots.txt
, how can I do that ? Maybe with the matcher ?
Thanks for this wonderful software !
Yes, with the path
matcher.
Please fill out the help topic template with your existing Caddyfile, and what you’ve tried so far, etc.
I read this, and now I have this config
git.eban.bzh {
root / /var/www/cgit/
file_server
encode zstd gzip
@notStatics {
path app /
not {
path *.(svg|css)
}
}
cgi @notStatics /run/fcgiwrap.socket {
env SCRIPT_FILENAME /var/www/cgit/cgit.cgi
env CGIT_CONFIG /etc/cgitrc
}
}
But it doesn’t work at all, I get a 404
I’m running Caddy v2.4.3 h1:Y1FaV2N4WO3rBqxSYA8UZsZTQdN+PwcoOcAiZTM8C0I= on Debian 11
[EDIT] The original nginx file is
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
include conf.d/tls.conf;
server_name git.eban.bzh;
root /var/www/cgit/;
try_files $uri @cgit;
error_log /var/log/nginx/error.log;
location @cgit {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/cgit.cgi;
fastcgi_param PATH_INFO $uri;
fastcgi_param QUERY_STRING $args;
fastcgi_param HTTP_HOST $server_name;
fastcgi_pass unix:/run/fcgiwrap.socket;
}
}
This isn’t correct. Path matching is exact in Caddy v2, so matching on /
will only match requests to exactly /
and nothing else. Instead, use *
to match all requests.
Same here. This only matches exactly /
. I don’t think that’s what you intended.
Instead of this, you could use the file
matcher to determine if the request is to a file that exists on disk. That would more closely match how the nginx config works, which uses try_files
.
Again, please fill out the help topic template. It’s unclear how you’re actually running Caddy or how you built it, so I have to start making assumptions and that wastes time for both of us.
This topic was automatically closed after 30 days. New replies are no longer allowed.