Show & Tell: Raspberry PI 3 B+ Network & Nginx Configuration #118
Replies: 7 comments
-
Thanks! It's fun to see your progress. I like your custom mounting / cable management. Re: avahi: too bad about that limitation. I wonder if it's a fundamental protocol limitation somehow that there's only one name per IP or if it's "just" that avahi doesn't support it. Maybe you could request several IP addresses on the Re: nginx RTSP: I hadn't thought of this, but apparently nginx supports plain TCP proxying, so RTSP-over-TCP should work. (Not RTSP-over-UDP unless nginx has specific RTSP protocol support that I missed.) RTSP-over-HTTP / RTSP-over-WebSockets should also be possible if your camera supports them. In my own setup I use routing to let my laptop access the camera UIs. I put my OpenWRT on both network segments and configured it route between them, with firewall rules so my "trusted" segment can initiate connections to "surveillance" but not vice versa. I suppose the NVR machine could also do the routing between the two, and you could have an OpenWRT router tell DHCP clients about that via something like |
Beta Was this translation helpful? Give feedback.
-
Thanks! Yeah, I'm aiming for a solution that could make the eventual setup a little more turn-key. The networking seems like the hardest part of an install. The rest could get stuffed in a docker more easily, right? (Though, I have nearly zero experience with Docker to talk). I found https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-udp-load-balancer/#configuring-reverse-proxy which I haven't attempted and don't fully understand. I found avahi/avahi#40 (comment) with a service definition hack that I haven't tried and don't fully understand. Being able to proxy UDP RTSP streams from the cameras is not so critical since ultimately the streams themselves will be visible in moonfire app anyway - except for various configurations that involve the image itself, I bet most camera UI will just be degraded about as much as not having the ActiveX plugin installed, which can't have much more life in them anyway. Moonfire will serve the video through a html video anyway, right? |
Beta Was this translation helpful? Give feedback.
-
It could. I haven't been focusing on improving the install experience (yet), but @dolfs contributed a It'd also be possible to make a
There's some hope. My old Hikvision DS-2CD2032 cameras have this problem. But my Dahua IPC-HDW5231R-Z (since a firmware upgrade a while back) no longer needs ActiveX. It works fine on Chrome on my Macbook Pro.
For recorded videos, yes. For live view, that's a feature in progress (#59) but in theory also yes. |
Beta Was this translation helpful? Give feedback.
-
@scottlamb this looks promising, but I haven't gotten it to work yet. https://askubuntu.com/questions/1175380/avahi-name-resolution-not-respected-for-subdomains-in-19-04#comment2118752_1189644 |
Beta Was this translation helpful? Give feedback.
-
@JasonKleban since StackExchange(AskUbuntu) comments are kind of limited, feel free to reach out to me here instead. If I understand the issue correctly, you've got an RPi device with this Moonfire project offered as a service and the camera reachable on a separate network IP but you want the RPi to proxy the IP+port with a subdomain via a reverse proxy like nginx? What's the intended flow here? The nginx config with IP addresses is going to remain manual? You just want zeroconfig for other systems to reach the RPi with several subdomains to interact with? As discussed on AskUbuntu, you're probably not going to get that without configuring clients to support (if even possible for the client), it'd be easier to provide your own local DNS at that point. I did also suggest just publishing multiple hostnames to point to the same device if needed. That should work just as well if subdomains aren't actually required. Do you see an issue with that approach? Any client that supports mDNS (not Android) would then have no issue? I noticed in my original answer I stated that publishing additional hostnames to the same IP would not be discovered, I believe that was due to not having a related service published to point to them for discovery, but that they should still respond to an mDNS lookup. If you need the ability to discover, it needs a service published to a domain and service type that would be searched/filtered. For example in the Instead of Avahi, you could also try mdns-publisher, which lets you use a config file that supports publishing multiple services to the same IP with different hostnames to respond to. |
Beta Was this translation helpful? Give feedback.
-
The goal is a turnkey ("zero-config"?) setup of moonfire with lan cameras directly reachable in a typical home network "wan"-side with no centralized dns or non-minimal manual configuration. Moonfire would have some minimal registration or discovery of cameras on the camera lans and reliably proxy inbound connections from wan for whatever variety of management software and protocols that each camera supports. I generally try to minimize the dependencies - I've seen reference to python scripts but I sense that such solutions are brittle. How reliably and seamlessly would topology updates be adjusted for? What extra cpu does running the python script take up? What additional knowledge must the operator know to troubleshoot this extra mechanism? What extra bugs will introduced by the complexity? If there's nothing lower-energy, then so be it. Just searching. |
Beta Was this translation helpful? Give feedback.
-
Is this in relation to you having control over everything that needs to know about the cameras? Or is a regular user meant to be able to just lookup If you need the user to have access to such, you need to consider the clients available to the audience. Windows/macOS and default Linux setups are not going to support multi-label mDNS lookups. You'll have to stick to single label. If you have full control of the device discovery/handling, and the user only needs to be concerned with their client accessing a single location (eg If the RPi has multiple services that need to be reachable via mDNS, since a Reverse Proxy is not going to be able to support subdomains to any client the user may have, if you need this functionality, publish with service prefixes on the hostname label (eg
I can't comment on that, it's not something I've needed enough to try. Presumably your network wouldn't be needing updates for this very often, but IIRC one of the Avahi python scripts uses DBUS API so it should update on the fly, whereas for a Golang binary like
Probably minimal, profile it if it's important to you, not likely to be a concern.
As you're aware the mDNS stuff can get complicated, especially when you get stuck and unsure of something as you encountered yourself. This wouldn't be much different I imagine, you should be comfortable with Google, contacting an author on Github, possibly looking into the Python code yourself, etc if you really need to. If it works as intended, you'd likely not have much to worry about. This should be transparent to the user, but their role is a bit vague (they're either only dealing with a client and have received access to the RPi and any other devices either setup for them already or with some instructions to follow), assuming the user doesn't need much technical competence, this shouldn't be something that bothers them, it'd be part of the complexity of the entire project they're relying on.
First you'd need to measure what exactly the complexity is and how that compares to the complexity already in the project to weigh that up. I would assume it's not worth worrying about it if it serves the required purpose well, you naturally are preferring additional complexity/burden to simplify and reduce burden on the user by not requiring them to know as much and minimize config/setup as much as possible.
The broader the audience/clients and the less control you have over the environment, the more effort it requires to support. If it were just a personal project and you knew it'd all be linux devices under your control, then you have a bit more freedom (such as using subdomains with mDNS). If you require HTTPS / TLS, you'll run into other problems for example. You won't be able to use LetsEncrypt for non-public domains, self-signed certs will often raise insecure warnings/errors from clients, and while you can provide your own private/internal CA signed certificates, the clients would need to add the CA public cert to their system trust stores, which imposes it's own security risks and complications. If this RPi device is meant to be reachable from the public internet however (presumably with some auth to restrict access), using a public domain you register makes all this easier, but may trade a different set of expectations on what a user would need to do that may or may not be better for that audience. |
Beta Was this translation helpful? Give feedback.
-
I want to share this netplan & nginx configuration so far. It is incomplete.
rpi3b+, usb drive dock, PoE injector, and HNC304-WDA (manufacturer unknown). Ethernet is for the camera(s) LAN and onboard wifi is for the external WAN.
I started with Ubuntu 20 64-bit for Raspberry PI image. I removed snapd for boot speed, added zram-config for eventual memory issues, and removed cloud-init and replaced it with the following Netplan .yaml configuration and added
sudo apt install avahi-daemon
for zeroconf mdns:I got moonfire working on port 8080 by the guides, but I want to also have access to the camera configuration directly. I think I could use a network bridge and firewall or port forwarding, but it seems that it will be easier to use Nginx. As of 10 years ago unfortunately, avahi seems to not support subdomains (aliasing) even though they seem easy to support in Nginx and would be the most user-friendly in my opinion (assuming that rtsp streams can be proxied with nginx too) compared to port numbers, and the most compatible compared to "virtual directory" mounting (by path). RTSP wouldn't work yet and I haven't really tried moonfire yet beyond being able to reach the page, but being able to configure the camera directly instead of having to physically plug in is nice. dhcp with camera hostnames mapped to a subdomain automatically would be even nicer - although every camera would need some kind of static configuration initially anyway...
Thoughts on this configuration?
Beta Was this translation helpful? Give feedback.
All reactions