MonocleCam and Caddy


(Paul Miles) #1

I’m trying to setup MonocleCam. I have caddy setup within in my network which is working well for my other stuff.
when trying to view my cameras using Alexa it cannot find my cameras.

Monocle was working well up to me introducing Caddy within my network.

Has someone managed to get this working? or could someone point me in the right direction to getting this resolved?

really appreciate any help on this, thank you.

https://monoclecam.com/


(Matthew Fay) #2

I have to admit I’m not sure how Caddy could get in the way.

Caddy talks HTTP(S) to your clients to serve web content. The app appears to use RTP and RTSP protocols to talk to your cameras. They shouldn’t be interacting at all, except if the app has a web page you’re proxying to.

How is Caddy configured?


(Paul Miles) #3

So i’m having to use monocle-gateway which uses port 443.
when running the setup for monocle-gateway it looks to bind the application with this port
setcap ‘cap_net_bind_service=+ep’ /usr/local/bin/monocle-gateway

Now when I run caddy -host *mydomain
i get error
listen tcp :443: bind: address already in use

if I stop monocle-gateway it works just fine.

I appreciate this isn’t a Caddy issue, but any help getting this working would be appreciated.

Thank you


(Matthew Fay) #4

Unfortunately you can’t have multiple programs listening on the same port. You’ll need to move monocle-gateway off port 443 so that Caddy can listen for HTTPS connections on that port.

Alternately, if Caddy isn’t at the edge of your network and you’re port forwarding from a router, you can move Caddy to a non-standard HTTPS port (8443 is a common alternative port) and have the router forward packets from 443 externally to 8443 on the Caddy host. It’s a bit more complicated than simply moving monocle-gateway, though.


(Paul Miles) #5

arh ok, thank you for this information. I have tried to change Monocle to use another port but I just don’t think it possible.

would it be possible in noobs terms to tell me how to setup caddy to use a different port.
so from what you have suggested in the above comment. I will need to setup a port forwarder on my router from 443 to 8443 which is fine.

what would I need to do with caddy to get this working?

I would really appreciate any help with this.


(Matthew Fay) #6

If the port forwarding is done, launch Caddy with the -https-port flag set to the port you’re forwarding to.

https://caddyserver.com/docs/cli#https-port


(Paul Miles) #7

Brilliant i have this working, I now want to get this to automatically start when I reboot raspberry Pi.

I have followed this guide before and it works just fine just not sure where I need to refence -https-port 8443
https://hostadvice.com/how-to/how-to-install-configure-the-caddy-web-server-on-an-ubuntu-18-04-vps/

Do i need to add something to my Caddyfile to enable the changes -https-ports 8443


(Matthew Fay) #8

You want this part:

sudo nano /lib/systemd/system/caddy.service

Modify the command:

ExecStart=/usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp

You want to add the switch to it, so the line should read:

ExecStart=/usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp -https-port 8443

Save it, then tell systemd to reload the unit file:

systemctl daemon-reload

Then start the service again if it’s not already running.


(Paul Miles) #9

Thank you for this, i will give this a try now.

I did notice that caddy offer a hook.service, would I be able to use this?
https://caddyserver.com/docs/hook.service

if so how would I add -https-port 8443


(Matthew Fay) #10

I think it just uses the run command you use to install the service with?

Just run the whole command and add -service install to it, and see if that works out. I believe it creates a systemd unit file if your init system is systemd, though, so you’re just as good to edit your existing unit file.


(Paul Miles) #11

Thank you for your help with this. I finally got this working.

I used the hook.service and then ammended systems unit file

ExecStart=/usr/local/bin/caddy -https-port 8443 -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp

Thank you again