From ZoneMinder Wiki

Jump to: navigation, search

zms-inetd is an inetd-wrapper for the ZMS (Zoneminder Streaming Server), so ZMS can work "standalone".



I'm using Zoneminder with Nginx Httpd, which doesnt support simple CGI (just FastCGI). So I needed a leightweight solution to make ZMS work without any extra software. This script depends only on inetd and bash.


Just copy and paste the zms-inetd-script from below (Section "Script") into a text file and save it, for example, as /usr/local/bin/zms-inetd. Don't forget to make it executable (chmod 755 /usr/local/bin/zms-inetd).


As for every inetd-service you have to define a port number in /etc/services:

zms-inetd       85/tcp   # Zoneminder ZMS inetd-wrapper


Of course also an entry in the inetd configuration is needed. Please adapt this to your needs (user [= www], path):

zms-inetd       stream tcp nowait    www   /usr/local/bin/zms-inetd  zms-inetd

Path to zm.conf

Set the ZMCONF variable in the shell-script appropriate.


The last step is to adjust the web path (URL) to ZMS. This is done through the ZM-Webinterface > Options > Paths > Web path to zms streaming server (ZM_PATH_ZMS). According to the configuration above this would be:


It doesn't matter which path you specifiy as zms-inetd will always proxy to the ZMS cgi-binary for security reasons.

Further thoughts

Make it transparent

In combination with Nginx its propably useful not to point ZM directly to the zms-inetd port, but mask it with a reverse proxy configuration in Nginx. That should avoid some problems if you want to reverse proxy the whole ZM installation (eg: from intranet to the internet).


 location /zm/zms-inetd {

Of course you have to adjust the cgi-bin path (ZM_PATH_ZMS) appropriate (eg: /zm/zms-inetd).

Other use cases for zms-inetd

Another scenario where zms-inetd perhaps could also be used is a leightweight or embedded system, just running ZMS. For example the busybox multibinary offers an inetd and a shell. Due the fact that zms-inetd is not heavily integrated with bash it should not be too hard to adapt it to ash (default shell in busybox).


# Inetd-wrapper for ZMS (Zoneminder Streaming Server)
# Version:      2007-09-27
# Author:       Kurt Zankl <>
# Inspiration:
# Requirements: bash, inetd
# License:      GNU General Public License, Version 2
# /etc/services:
#   zms-inetd       85/tcp   # Zoneminder ZMS inetd-wrapper
# /etc/inetd.conf:
#   zms-inetd       stream tcp nowait    www-data   /usr/local/bin/zms-inetd  zms-inetd
# ZM Options / Paths / Web path to zms streaming server:
#   ZM_PATH_ZMS = http://<server>:85/<anypath>

# configuration

# error handler
function errormsg {
  echo "HTTP/1.0 500 Internal Server Error"
  echo "Content-Type: text/html"
  echo "<title>ERROR</title><h1>ERROR</h1>"
  echo -e "<pre>$1</""pre>"
  exit 1

# get request
# skip headers
HEADER="nothing"; while [ "$HEADER" != $'\r' -a -n "$HEADER" ]; do read HEADER; done

# read ZM configuration
[ -r $ZMCONF ] || errormsg "Error reading Zoneminder configuration \"$ZMCONF\""
[ -x $ZMS ] || errormsg "Error finding ZMS executable \"$ZMS\""

# check request
[ -z "$REQUEST" ] && errormsg "Request is empty"

# split request
URL="${URL% HTTP/*}"

# check query
[ "$QUERY" == "$URL" ] && errormsg "Invalid query"

# execute ZMS
# (STDERR output is discarded as this confuses MPEG streaming clients)
echo "HTTP/1.0 200 OK"
"$ZMS" 2>/dev/null
exit 0
Retrieved from "?title=Zms-inetd&oldid=7579"