Stop
Running multiple instances of OctoPrint on one Pi is not officially supported. Please refer to this FAQ entry:
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
99-usb.rules:
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"
fi
so like this
#if [ -e "/boot/octopi.txt" ]; then
# source "/boot/octopi.txt"
#fi
/etc/haproxy/haproxy.cfg
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
global
maxconn 4096
user haproxy
group haproxy
tune.ssl.default-dh-param 1024
log 127.0.0.1 local1 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
option forwardfor except 127.0.0.1
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 127.0.0.1:5000
backend octoprint2
reqrep ^([^\ :]*)\ /(.*) \1\ /\2
reqadd X-Scheme:\ https if { ssl_fc }
option forwardfor
server octoprint2 127.0.0.1:5001
backend webcam
reqrep ^([^\ :]*)\ /webcam/(.*) \1\ /\2
server webcam1 127.0.0.1:8081
backend webcam2
reqrep ^([^\ :]*)\ /webcam/(.*) \1\ /\2
server webcam2 127.0.0.1:8082
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
http://cr10-a.mydomainname.com:81 takes me to backend octoprint, my first printer
http://cr10-b.mydomainname.com:81 takes me to backend octoprint2, my second printer
http://cr10-a.mydomainname.com:81/webcam/ takes me to backend webcam, my first printers webcam
http://cr10-b.mydomainname.com:81/webcam/ takes me to backend webcam2, my second printers webcam
http://cr10-a.mydomainname.com:81/webcam/?action=stream takes me to backend webcamstream, my first printers webcam stream
http://cr10-b.mydomainname.com:81/webcam/?action=stream takes me to backend webcamstream2, my second printers webcam stream
That's about it.