Ok so after some back and forth, I finally got a working Caddyfile for Zoneminder. This includes all web functionality, as well as the ZMninja app.
{
order cgi before respond
}
:80 {
root * /usr/local/www/zoneminder
redir / /zm/ 308
handle_path /zm/cache* {
root * /var/cache/zoneminder
}
handle_path /zm*
handle /api* {
rewrite * /api/app/webroot/index.php?p={path}&{query}
}
cgi /cgi-bin/nph-zms /usr/local/www/zoneminder/cgi-bin/nph-zms {
unbuffered_output
}
php_fastcgi unix//var/run/php-fpm.sock
file_server
}
It is necessary to build caddy with the cgi plug-in.