Setting up OctoPrint on a Raspberry Pi for multiple printers

:raised_hand: Stop

Running multiple instances of OctoPrint on one Pi is not officially supported. Please refer to this FAQ entry:

Multiple printers per server megathread

Just a link for now to a guide that works
Setting up OctoPrint on a Raspberry Pi for multiple printers

A couple of notes from my own experience following this guide.
Adding a second webcam
If you have two of the exact same webcams the filtering doesn't work if your camera doesn't have a serial number, mine didn't.
Workaround: Use a USB hub, on the hub I used each port had its own identifier under the KERNALS tag
KERNELS=="1-1.2.1" and KERNELS=="1-1.2.2" for my hub was port 1 and 2

/root/bin/webcamd and webcamd2
I recommend using 8081 for webcamd and 8082 for webcamd2

Also I needed to comment out these lines in webcamd and webcamd2

if [ -e "/boot/octopi.txt" ]; then
    source "/boot/octopi.txt"

so like this

#if [ -e "/boot/octopi.txt" ]; then
#    source "/boot/octopi.txt"

Because of the above change, the haproxy needs to be a little different. Notice the ports in the backend.
This is mine as an example

        maxconn 4096
        user haproxy
        group haproxy
        tune.ssl.default-dh-param 1024
        log local1 debug

        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
        option forwardfor except
        acl host_CR10-A hdr_beg(host) -i CR10-A
        acl host_CR10-B hdr_beg(host) -i CR10-B
        use_backend webcam if { path_beg /webcam/ } host_CR10-A
        use_backend webcam2 if { path_beg /webcam/ } host_CR10-B
        use_backend octoprint if host_CR10-A
        use_backend octoprint2 if host_CR10-B
        default_backend octoprint
        errorfile 503 /etc/haproxy/errors/503-no-octoprint.http

backend octoprint
        reqrep ^([^\ :]*)\ /(.*) \1\ /\2
        reqadd X-Scheme:\ https if { ssl_fc }
        option forwardfor
        server octoprint1

backend octoprint2
         reqrep ^([^\ :]*)\ /(.*) \1\ /\2
         reqadd X-Scheme:\ https if { ssl_fc }
         option forwardfor
         server octoprint2

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

backend webcam2
        reqrep ^([^\ :]*)\ /webcam/(.*)     \1\ /\2
        server webcam2
        errorfile 503 /etc/haproxy/errors/503-no-webcam.http

And for accessing outside the network because of how I setup my haproxy I only need one port open, 81

I am using my domain, with an a record to point to my home ip address

The haproxy rules work like this for me takes me to backend octoprint, my first printer takes me to backend octoprint2, my second printer takes me to backend webcam, my first printers webcam takes me to backend webcam2, my second printers webcam takes me to backend webcamstream, my first printers webcam stream takes me to backend webcamstream2, my second printers webcam stream

That's about it.


9 posts were merged into an existing topic: Multiple printers per Pi megathread