Convert Nginx to Caddy (Zoneminder)

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.

1 Like

The only other issue I have (and this may warrant a new thread) is running caddy as the www user.

If I run caddy as www I need to have the port set at a high number because of bind privileges. If I run caddy as root, the stream flickers.

You probably need to sudo setcap cap_net_bind_service=+ep ./caddy or whatever. You’re using FreeBSD though so I’m no help regarding that, I have no idea how that’s done in BSD-land.

In Linux with systemd, we recommend using these setup instructions, which set up a caddy user with appropriate permissions Keep Caddy Running — Caddy Documentation

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