Multi-Server LiveStream using external Hostname

Forum for questions and support relating to the 1.30.x releases only.
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Multi-Server LiveStream using external Hostname

Post by knight-of-ni »

That's a nice setup. I really like playing with the rasp pi's. I configured multi-server for the first time with a rasp pi 2 as well. I've got several myself with more potential ideas than I have time to try them.

Since the early versions of ZoneMinder, it has always been possible to have multiple servers for a single surveillance system. One could achieve different results by sharing or replicating databases, sharing storage through nfs, glusterfs, etc, or just running two entirely independent servers. This can be achieved today, without making any changes to the ZoneMinder source code. Doing it this way is firewall friendly as long as you've got the proper port forwarding setup correclty on your firewall. The one common drawback from doing it this way is that you are duplicating resources across all your servers. There is a set of zm* processes running, for each camera, on each server. On a large system, this is a show stopper because it doesn't scale. On a small system, maybe you don't even notice.

Multiserver was written specifically to address that one issue. Because only one set of processes is running for each camera, between all the servers in the system, it is the only solution that is indefinitely scalable. That is what makes it different from the other mode. This is also why the URL's have to point to the other servers, because one can only stream from the server with the running process.

In time, I expect us to develop something native to ZoneMinder that essentially proxies, automatically, all the cameras through the server you are viewing from, but don't expect that to happen anytime soon. We are doing this, for free, in our spare time, mind you.

We can't use the change you suggested, because that change expects all the zm* processes, for all cameras, to be running on the server you are browsing from. That currently isn't the case if multiserver is configured correctly. We can look into your system if you want to try and figure out why that does not appear to be the case.
Now, if I log in from outside it behaves differntly. Let's say I have external host name zm.myhome.com and I use port 780 as my forwarding port to SERVER-LNX port 80. I type in http://zm.myhome.com:780/zm in the browser and get to dashboard. I can view any event recorded but not livestream. Inspecting (right click Inspect in Chrome) object gives me URL that gave in my first post of this thread.
<img id="liveStream" src="http://SERVER-LNX/zm/cgi-bin/nph-zms?mo ... &monitor=2" alt="CAM01" width="1280" height="720">
You can fix this part of the issue by giving your server the same name as your dyndns name. Rename SERVER-LNX to "zm", set your local dns domain to "myhome.com", and add a DNS A record to your local dns which points to your local ip address so your local browsing doesn't break. That's how one normally does this kind of thing. Of course, it doesn't fix access to SERVER-RPI.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Multi-Server LiveStream using external Hostname

Post by knight-of-ni »

You can fix this part of the issue by giving your server the same name as your dyndns name. Rename SERVER-LNX to "zm", set your local dns domain to "myhome.com", and add a DNS A record to your local dns which points to your local ip address so your local browsing doesn't break. That's how one normally does this kind of thing. Of course, it doesn't fix access to SERVER-RPI.
I've been thinking a little futher about what I said, and I think you might be able to avoid changing the actual hostname on the box.
You might be able to get away with setting ZM_SERVER_HOST=zm.myhome.com and then setting a dns A record on your local dns to map that to a local ip, instead of your internet ip, so local browsing continues to work.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
User avatar
iconnor
Posts: 2900
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Multi-Server LiveStream using external Hostname

Post by iconnor »

Event view will work everywhere assuming the external server has access to the stored event files.

Live view must be able to connect to the recording server (or use the external server as a reverse proxy to the internal recorders).

Here's my setup:
server1 external, live on web at server1.domain.com, and will also respond to server2.domain.com
server2 internal, responds to server2.domain.com

in the internal network, dns resolves to a 192.168.1.* for server2.domain.com and server1.domain.com.
Externally, both server1.domain.com and server2.domain.com resolve to the same ip address of server1.domain.com.
server1 is setup as a reverse proxy for server2. So the links work.
kulshyn
Posts: 9
Joined: Tue Aug 02, 2016 12:25 pm

Re: Multi-Server LiveStream using external Hostname

Post by kulshyn »

I followed above suggestions and reverted code change. One thing I realized, hostname can contain port. So I set both of my ZMs to my.domain.com:781 and my.domain.com:782. I forwarded 781 to 80 of server1 and 782 to 80 of server2.
Now it works through web ui internally and externally.
I still however have issue with zmNinja.
Locked