motioneyeos
motioneyeos copied to clipboard
Reverse proxying MotionEyeOS (with Caddy)
Hi,
I have MotionEyeOS working on a rpi-zero, accessible on my local network, at meye.lan.
I'm trying to set up Caddy as a reverse proxy on a separate machine to allow access from outside the LAN.
Reverse proxying the main part of MEOS works fine, but the camera feed doesn't appear:

I understand this is because the camera feed is actually pulled from meye.lan:8081.
I'd rather not have to open that port to the Internet and would like to have Caddy reverse proxy both the main app (meye.lan) and the video feed (meye.lan:8081).
I've tried following the instructions on the MotionEye wiki but either they are out of date or MotionEyeOS is just too different, because both the /cams/ and /mjpeg/ paths are 404 on MotionEyeOS.
Here is the relevant part of my Caddyfile config:
monitoring.tld {
redir /meye /meye/
handle_path /meye/* {
reverse_proxy meye.lan
}
## different but related service, running in a local container
reverse_proxy 127.0.0.1:8000 {
header_up Host {upstream_hostport}
}
}
(this makes my main service be served at https://monitoring.tld, and MotionEye served at https://monitoring.tld/meye)
Basically, i haven't figured out how to proxy the requests meye.lan makes to meye.lan:8081 in Caddy (yet!). Any clues appreciated!
Thanks!
motionEyeOS Version
dev20201026
Board Model
Raspberry Pi Zero
Camera
I am using the following type of camera: Simple MJPEG Camera (fast network camera)
My camera model is: Night Vision Camera Module
Network Connection
Wifi
Peripherals
no relevant peripherals
Log Files
no relevant log files
You can change the port used by the camera from 8081 to whatever you prefer in the file: /data/etc/camera-1.conf (stream_port) However, it is known to work with nginx but the folder references you are using aren't folder references in motionEye or motionEyeOS, they are tags within nginx. Given time, and any other's interest, I might check out how to set up your Caddy port forwarder... And what kind of containerization are you using? Is just Caddy in a container, or is motionEye being run in a container, too? Or even in the same container? and here is the port documentation for mEOS:
The setup is:
- mEOS running on a rpi-zero-w, with one cam
- NixOS running on a rpi4
- Caddy running directly on NixOS
- other related service running in a container, reverse proxied by Caddy
And as i was saying, i'd like to have Caddy reverse proxy the whole of mEOS, not just the main webpage.
Thanks for your answer in any case, @starbasessd !
Which NixOS? Which container system? What 'related services'? Looks like I might have time to spin one up this weekend...
My 'which NixOS' means which version did you start with, what updates, etc, because I may not be able to hit the same intermediary version that you have because of the way they handle updates...
Which NixOS, you mean version ? This is on 22.05. Using oci-containers and podman. I see your point regarding nix derivations and all that, but i think that's not really relevant, since that part works fine and doesn't touch MotionEyeOS in any way that i can think of.
The part that matters is that i'm trying to reverse proxy all of the parts that make up mEOS on a path of my domain, so, after re-reading the MotionEye nginx documentation, similar to how it serves MotionEye on /cams/.
Lastly, my ideal goal is not to have to open an extra port on my router's firewall. I think that if i can reverse proxy something at 127.0.0:1:8000 i should be able to reverse-proxy something at meye.lan:8081.
I will try to re-create your environment. Are you trying to reverse proxy all the ports for all the apps to a single port? That won't work. How would you differentiate between the effective sites? IOW if I connect to the outside firewall to port 56789, and the router points to NixOS:8000, I can't have it go to PiCam:8081 without a BUNCH of changes. Also, did you try going to port 80 on the PiCam instead of 8081? You might be able to create a web server which pulls all the web pages from your apps and put them in a single page, then reverse proxy that...
Are you running NixOS, or NixOS Package Manager on Raspbian? 32 bit or 64 bit? That is a weird setup...