1. The problem I’m having:
I am trying to configure caddy for use with Zoneminder. The problem is that there are a number of location and alias blocks that I am having a hard time getting to work.
The main webpage seems to work, but the api has some issues.
2. Error messages and/or full log output:
No error logs yet. Just working on the Caddyfile for now. If needed I can provide.
3. Caddy version:
2.6.4
4. How I installed and ran Caddy:
‘pkg install caddy’
‘service caddy start’
a. System environment:
FreeBSD 13.2 Jail
b. Command:
See above.
service caddy start
d. My complete Caddy config:
192.168.1.156:80 {
root * /usr/local/www/zoneminder
try_files {path} {path}/index.php
php_fastcgi 127.0.0.1:9000
handle /zm/cache* {
root * /var/cache/zoneminder
}
handle /zm/api/* {
root * /usr/local/www/zoneminder
rewrite /zm/api/* /usr/local/www/zoneminder/api/app/webroot
php_fastcgi 127.0.0.1:9000
}
handle /zm* {
root * /usr/local/www/zoneminder
php_fastcgi 127.0.0.1:9000
}
}
Here is the nginx config file.
server {
listen 80;
root /usr/local/www/zoneminder;
index index.php
gzip off;
location /cgi-bin/nph-zms {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/fcgiwrap/fcgiwrap.sock;
}
location /zm/cache {
alias /var/cache/zoneminder;
}
location /zm {
alias /usr/local/www/zoneminder;
location ~ \.php$ {
if (!-f $request_filename) { return 404; }
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php-fpm.sock;
}
location ~ \.(jpg|jpeg|gif|png|ico)$ {
access_log off;
expires 33d;
}
location /zm/api/ {
alias /usr/local/www/zoneminder;
rewrite ^/zm/api(.+)$ /zm/api/app/webroot/index.php?p=$1 last;
}
}
}
I have also tried without the rewrite line under the handle /zm/api/ block with no change.
5. Links to relevant resources:
I am trying to follow the Nginx file linked to here, but can’t seem to get it quite right.