Setting up Multiple OctoPi


#1

What is the problem?
Wanting to set up a 2nd independent Octopi for a 2nd printer in another room, and I'm not quite understanding what I need to do about port forwarding so that I can connect to either one remotely.

What did you already try to solve it?
Just reading on here. but can't see where anyone has multiple RPi's set up for remote access... or am I simply searching with bad key words...???

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, octoprint.log, serial.log or output on terminal tab, ...)
I have two RPi 3 B, with webcams attached.
Running the flash I d/l from here named "octopi-stretch-lite-0.15.1"

Set my router up for port forwarding of port 80 to my first Pi/printer rig and also setup dynamic DNS to use "no-ip.org" for remote access.
Now I want to set up for a 2nd Pi and Printer, but with the default port 80 being used in rig 1, I don't know what to do about the 2nd setup as far as what port to use for communicating or how to change it on the 2nd octopi rig.

I have a little computer savvy, but when it comes to remote access, I'm still a little behind the curve. Thanks in advance!!


#2

You cannot see them on the same port, you have 2 options

forward the second port to your router, so just like you access your first one with

http://lalla.no-ip.org

you will access your second one with (if you forward port 81 to second printer) for e.g.

http://lalala.no-ip.org:81

that's one way to go about it, the second way is, check out on first printer you have HA installed, you can modify HA config to add a location e.g. /printer2/ and leave the router as is but access your second printer as

http://lalala.no-ip.org/printer2/

e.g. default would look like this

global
        maxconn 4096
        user haproxy
        group haproxy
        daemon
        log 127.0.0.1 local0 debug

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        option http-server-close
        option forwardfor
        maxconn 2000
        timeout connect 5s
        timeout client  15min
        timeout server  15min

frontend public
        bind :::80 v4v6
        use_backend webcam if { path_beg /webcam/ }
        default_backend octoprint

backend octoprint
        reqrep ^([^\ :]*)\ /(.*)     \1\ /\2
        option forwardfor
        server octoprint1 127.0.0.1:5000

backend webcam
        reqrep ^([^\ :]*)\ /webcam/(.*)     \1\ /\2
        server webcam1  127.0.0.1:8080

what you want is add another backend so something like this will work for your need assuming your second printer is available at http://192.168.0.222:5000

global
        maxconn 4096
        user haproxy
        group haproxy
        daemon
        log 127.0.0.1 local0 debug

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        option http-server-close
        option forwardfor
        maxconn 2000
        timeout connect 5s
        timeout client  15min
        timeout server  15min

frontend public
        bind :::80 v4v6
        use_backend webcam if { path_beg /webcam/ }
        use_backend secondoctoprint if { path_beg /printer2/ }
        default_backend octoprint

backend octoprint
        reqrep ^([^\ :]*)\ /(.*)     \1\ /\2
        option forwardfor
        server octoprint1 127.0.0.1:5000

backend webcam
        reqrep ^([^\ :]*)\ /webcam/(.*)     \1\ /\2
        server webcam1  127.0.0.1:8080

backend secondoctoprint
        reqrep ^([^\ :]*)\ /(.*)     \1\ /\2
        option forwardfor
        server octoprint2 192.168.0.222:5000

#3

the issue with second (HA) approach is that if first RPI is shutdown you can't see the second printer!

but tbh are you really sure you want to expose your printer to the wan, is not very secure? these devices are not built for security? why not use something like telegram plugin ? you keep your devices behind nat but you can have full control over them trough telegram?


#4

So using option 1, I don't have to tell the 2nd rig to listen on port 81? Just forward 81 to rig 2's LAN IP? wouldn't that suggest that I could use any port that wasn't already in use? The last time I messed with remote stuff (several years ago and unrelated to this) I had to set the application to listen on whatever port I decided to use, Forward that port in the Router, and also set the app on the remote end to use same port.

In reality I may be overkilling Rig 2. I don't plan on controlling Rig 2 at all, just want to stream the webcam to the net. Printer 2 is a Beta model of the new Silhouette Alta, and the stream is to be used for discussion in the beta groups, so I'm sure that there is a better alternative to accomplish this, but since I was familiar a little with the ease of setup of Octoprint, it just seemed like an easy solution to use.


#5

when you are setting forwarding you set port on router and ip+port on the lan ... by default they are the same but you can set them to be different so you want to forward router port 81 to rig's ip but with port 80, not port 81

well you need to know the port on the router you are forwarding so you know how to access it from outside. also you need to know on what port your octoprint is listening (default 5000 iirc but pushed to 80/443 trough HA) .. so yes it can be any unused port but it can't be a random one.

also instead of forwarding 80 to ip1:80 and 81 to ip2:80 I suggest you forward 443 to ip1:443 and 444 to ip2:443 and use https://dyndnsname/ for one and https://dyndnsname:444/ for second.. just so you add a tiny little layer of security there...

having a whole bunch of ppl connecting to your streaming services can both kill your pi and be very very unproductive, not to say, unsafe.. why don't you just create a live stream from your rig2 to some internet service? e.g. OctoPrint-YouTubeLive