ZoneMinder is widely renowned in the industry as a robust and versatile open-source software for Closed-Circuit Television (CCTV) surveillance. Although the software boasts numerous features and customization options, the official documentation often leaves some gaps. For instance, the standard installation guide focuses on subdirectories and lacks comprehensive details for setting up the software on a custom domain. Utilizing ZoneMinder on a distinct domain or subdomain can be particularly beneficial for specialized applications like surveillance technology or for logically separating various services.
In light of this, we offer a specialized guide that focuses exclusively on integrating ZoneMinder with a custom domain via nginx, specifically configured and tested on Debian systems. This guide was created for Debian 11 and ZoneMinder 1.36.33.
nginx Configuration
To make ZoneMinder accessible on a custom domain, you'll need a unique server configuration. Alternatively, you can adapt an existing configuration if the domain is not already in use. Our base configuration for nginx, stored under
/etc/nginx/sites-enabled/zoneminder.example.com
, employs its own subdomain along with SSL encryption.
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name zoneminder.example.com;
ssl_certificate /etc/ssl/fullchain.pem;
ssl_certificate_key /etc/ssl/privkey.pem;
ssl_protocols TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/ssl/dhparam.pem;
}
This can be used as a template for your own deployment. In the server block, you'll need to specify the path where ZoneMinder's folders are located and make them accessible. With a standard Debian installation, these paths should match most setups. Add this to your server block:
root /usr/share/zoneminder/www;
index index.php;
location /cgi-bin {
gzip off;
if_modified_since off;
expires off;
etag off;
alias /usr/lib/zoneminder/cgi-bin;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param HTTP_PROXY "";
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location /zm/cgi-bin {
gzip off;
if_modified_since off;
expires off;
etag off;
alias /usr/lib/zoneminder/cgi-bin;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param HTTP_PROXY "";
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location /cache {
alias /var/cache/zoneminder/cache;
}
location / {
gzip off;
if_modified_since off;
expires off;
etag off;
try_files $uri $uri/ /index.php?$args =404;
location ~ /api/(css|img|ico) {
rewrite ^/api(.+)$ /api/app/webroot/$1 break;
try_files $uri $uri/ =404;
}
location /api {
alias /usr/share/zoneminder/www/api;
rewrite ^/api(.+)$ /api/app/webroot/index.php?p=$1 last;
}
}
PHP-FPM Support
If you lack general PHP file handling in your nginx configuration, or if PHP isn't installed, you'll need to add a specific location block to the server configuration:
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
The path to the PHP-FPM socket may need adjustment. Ensure you have PHP 8.0 or above along with the
php
and php-fpm
packages installed.
Fcgiwrap
For CGI scripts, ZoneMinder employs fcgiwrap. After installing the package, it should create a socket
under /var/run/fcgiwrap.socket
. No standard modifications are required; however, if you encounter
CGI issues, appending DAEMON_OPTS=-c 10
in the /etc/default/fcgiwrap
file may resolve them.
ZoneMinder Configuration
Before reloading the new configurations, you should update certain URL parameters in your existing ZoneMinder installation.
Navigate to Options -> Servers
and update the following fields to ensure smooth operation:
- URL: The new URL, in our example
https://zoneminder.example.com
- PathToIndex:
/index.php
- PathToZMS:
/cgi-bin/nph-zms
- PathToApi:
/api
Relaunching Services: nginx and ZoneMinder
After configuring both nginx and ZoneMinder, the final step involves reloading or restarting the services.
Execute systemctl reload nginx
and systemctl restart zoneminder
, carefully monitoring for errors
that usually occur due to incorrect configurations.
If you installed php-fpm
or fcgiwrap
, double-check that the sockets are available.
ZoneMinder should now be accessible on your custom domain, as well as its API.
Mobile Compatibility
Although primarily designed for desktop usage, ZoneMinder's utility on mobile devices should not be overlooked. We have long used the "zmNinja" app, which is no longer in active development but still functions flawlessly for us. It seamlessly integrates your ZoneMinder installation and offers convenient access to your surveillance cameras and recordings.
Conclusion
Setting up ZoneMinder on a custom domain may seem technically challenging, but thanks to our in-depth guide, it's now quite manageable. We have invested numerous hours to perfect this configuration, ensuring it also works seamlessly with mobile apps.
We have been using ZoneMinder with this setup for many months without any issues, and we hope you will too.
If you have any questions or need further assistance in this area or other IT challenges, Neoground GmbH stands ready as your partner for digital solutions. Feel free to share your thoughts and questions in the comments. Contact us, and let's drive your digital transformation together!
This post was created with the support of artificial intelligence (GPT-4). Cover photo by Lianhao Qu on Unsplash
->> No comments yet
Add a comment