NGINX SAGA - NO STREAM WEB + NO API VALIDATION zmNINJA

Forum for questions and support relating to the 1.34.x releases only.
Post Reply
davew
Posts: 8
Joined: Sat Jul 04, 2020 5:33 am

NGINX SAGA - NO STREAM WEB + NO API VALIDATION zmNINJA

Post by davew »

PLEASE HELP

Been at it for 2days and 2 nights now.

New User to ZoneMinder, but not to building web servers. I've built a few systems in the past for personal use (Nextcloud, Wekan, Matrix-Synapse Server, OpenProject) and now I'm building a ZoneMinder. The problem with this software is that there is a lot of conflicting information about settings. I'm posting here what I have to hopefully resolve a latest install.

FRESH WIPE. Just did a fresh install few minutes ago and things went smoother this time around. Something is up with my API validation and access to nph-zms for live streaming.

PROBLEMS
1. streaming from web page
2. ZMninja API can't validate

RUNNING:
ZM 1.34.16
Ubuntu 18.04 LTS
NGINX
MySQL
PHP7.3

SOME PARAMETERS I'VE RECENTLY SET
1. CGI-BIN OWNERSHIP. chown -R www-data:www-data /usr/lib/zoneminder/cgi-bin

2. ZM.CONF. Updated /etc/zm/zm.conf

Code: Select all

ZM_DB_PASS=
3. SYSTEM PATHS. UPdated /etc/zm/conf.d/01-system-paths.conf

Code: Select all

# ZoneMinder url path to the zms streaming server
#ZM_PATH_ZMS=/zm/cgi-bin/nph-zms
ZM_PATH_ZMS=/cgi-bin/nph-zms
4. WITHIN ZONEMINDER. Inside ZoneMinder, I've set Options:
OPT_USE_AUTH - Yes
AUTH_RELAY - none
AUTH_HASH_SECRET - blank
AUTH_HASH_IPS - No
AUTH_HASH_LOGINS - No

5. CAMERA OUTPUT. Matches Codec & Resolution of what was shown in VLC.
1920x1080p
H264 Camera Passthrough

6. TIMEZONE. Set in Options > System > TIMEZONE within Zoneminder. Also set from previous install in php7.3-fpm.ini.

Other than that, besides some of the nuance settings like storage, save jpegs, everything is at default setting on the system and server.

I'm pretty sure it's a problem with my NGINX declration of cgi-bin and api. I'm not sure what I might be doing wrong. I decided to keep the entirety of my NGINX configuration in one file so that I can have one place to manage the NGINX configuration. See NGINX configuration below.

BELOW IS MY NGINX CONFIGURATION.

Code: Select all

server {
    listen 80;
    listen [::]:80;
    server_name <domain.org> security.<domain.org>;
    # enforce https
    return 301 https://$server_name$request_uri;
}

server {
    listen 444 ssl;
    listen [::]:444 ssl;
    server_name <domain.org> security.<domain.org>;
    ssl_certificate /etc/letsencrypt/live/security.<domain.org>/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/security.<domain.org>/privkey.pem; # managed by Certbot
    root /usr/share/zoneminder/www; 
    index index.php index.html index.htm index.nginx-debian.html;
    try_files $uri $uri/ /index.php?$args =404;    
    
    location ~ \.php$ {
      if (!-f $request_filename) { return 404; }
      expires epoch;
      include /etc/nginx/fastcgi_params;
      fastcgi_param SCRIPT_FILENAME $request_filename;
      fastcgi_param HTTP_PROXY "";
      fastcgi_index index.php;
      fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
    }
      
    location /zm {
      gzip off;
      alias /usr/share/zoneminder/www;
      try_files $uri $uri/ /index.php?$args =404;
      index index.php;
    }

    location ~ /zm/api/(css|img|ico) {
      auth_basic off;
      rewrite ^/zm/api(.+)$ /api/app/webroot/$1 break;
      try_files $uri $uri/ =404;
    }

    location ~ \.(jpg|jpeg|gif|png|ico)$ {
      access_log  off;
      expires 33d;
    }

    access_log /var/log/nginx/security.<domain.org>-ACCESS.log;
    error_log  /var/log/nginx/security.<domain.org>-ERROR.log;

    location /cgi-bin {
      gzip off;
      auth_basic off;
      alias /usr/lib/zoneminder/cgi-bin;      
      include /etc/nginx/fastcgi_params;
      fastcgi_param SCRIPT_FILENAME $request_filename;
      fastcgi_param HTTP_PROXY "";
      fastcgi_pass unix:/var/run/fcgiwrap.socket;
    }

    location /cgi-bin/nph-zms {
      auth_basic off;
      alias /usr/lib/zoneminder/cgi-bin/nph-zms;
    }

    location /zm/cache {
      auth_basic off;
      alias /var/cache/zoneminder/cache;
    }

    location ~* /zoneminder/.*\.(m4a|mp4|mov)$ {
      mp4;
      mp4_buffer_size 5M;
      mp4_max_buffer_size 10M;
    }
}
davew
Posts: 8
Joined: Sat Jul 04, 2020 5:33 am

Re: NGINX SAGA - NO STREAM WEB + NO API VALIDATION zmNINJA

Post by davew »

ERROR LOGS

web_js.log
07/04/20 15:55:59.007831 web_js[17523].ERR [127.0.0.1] [getStreamCmdResponse stream error: Socket /var/run/zm/zms-036903s.sock does not exist. This file is created by zms, and since it does not exist, either zms did not run, or zms exited early. Please check your zms logs and ensure that CGI is enabled in apache and check that the PATH_ZMS is set correctly. Make sure that ZM is actually recording. If you are trying to view a live stream and the capture process (zmc) is not running then zms will exit. Please go to http://zoneminder.readthedocs.io/en/lat ... window-etc for more information. - checkStreamForErrors()] at ?view=watch line

web_php.log
07/04/20 15:56:52.022345 web_php[17523].ERR [127.0.0.1] [Socket /var/run/zm/zms-638163s.sock does not exist. This file is created by zms, and since it does not exist, either zms did not run, or zms exited early. Please check your zms logs and ensure that CGI is enabled in apache and check that the PATH_ZMS is set correctly. Make sure that ZM is actually recording. If you are trying to view a live stream and the capture process (zmc) is not running then zms will exit. Please go to http://zoneminder.readthedocs.io/en/lat ... window-etc for more information.] at includes/functions.php line 2177

OBSERVATIONS
When navigating to /var/run/zm, two (2) + one (1) files exist:

1 zm.pid www-data:www-data 644
2. zdmc.sock www-data:www-data 755
3. zms-######.sock www-data:www-data 755

PROBLEMS WITH ABOVE. The 3rd .sock file appears and then disappears. Each file is assigned a unique number and then disappears.
Post Reply