I have two printers and I am thinking about getting a third printer. I would like to hit OctoPrint from my work and check up on both printers (and soon all three printers). However, I can only forward the external ip address to one OctoPrint. Can we add a button or menu choice that allows us to switch over to the other internal ip addresses so we can view the other OctoPrint servers?
Are you running them on the same pi?
http://thomas-messmer.com/index.php/14-free-knowledge/howtos/79-setting-up-octoprint-for-multiple-printers
I have two printers on the same pi that I can access individually from outside my network.
printer 1 is at cr10-a.myaddress.com
printer 2 is at cr10-b.myaddress.com
I'll give a quick rundown of what I have done besides what is in the link above.
- I own a domain so I put an A record pointing to my home IP address with a host of cr10-a and cr10-b
- see image for port forwarding info for your router (2 printers and 2 webcams)
- My haproxy looks like this
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
use_backend webcam if { path_beg /webcam/ }
use_backend webcam2 if { path_beg /webcam2/ }
acl host_CR10-A hdr_beg(host) -i CR10-A
acl host_CR10-B hdr_beg(host) -i 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
frontend webcamonly
bind *:9080
option forwardfor except 127.0.0.1
default_backend webcamstream
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:8080
backend webcam2
reqrep ^([^\ :]*)\ /webcam2/(.*) \1\ /\2
server webcam1 127.0.0.1:8082
errorfile 503 /etc/haproxy/errors/503-no-webcam.http
backend webcamstream
reqrep ^([^\ :]*)\ /(.*) \1\ /\?action=stream
server webcam1 127.0.0.1:8080
webcam2 is set to 8082 instead fo 8080 like the above url states
Also...make sure to change your pi's login password and secure your octoprint with a good password also so if someone does happen on it you got something.
The two things I would suggest in this case is to either port forward from a different external port, or simply use a VPN solution.
VPN is the best, as you are not allowing the pis access from the outside. If VPN is not a solution for you then you can do an outside port forward from say 81 to inside port 80.
Assuming your outside IP address was 1.2.3.4, pi 1 was 192.168.0.11 and pi two was 192.168.0.12, you would enable 1.2.3.4 port 80 to 192.168.0.11 port 81, and 1.2.3.4 port 82 to 192.168.0.12 port 80. You can then access them via http://1.2.3.4:81 and http://1.2.3.4:82. It seems complicated, but it is not.
It seems @Zoombee beat me to a reply. That is a different solution. A fourth solution I just realized was to use something like octoprint anywhere. There are multiple ways to do this. Pick your poison!
Also, to rid of having to remember the ip, you can use a service like https://www.noip.com/free to get a sudo domain name.
I've updated my method to reduce open ports to one while still being able to goto octoprint, /webcam and /webcam/?action=stream
I put it all in a post in guides where I also point out what I did different from the guide I posted above.
Guide:Setting up OctoPrint on a Raspberry Pi for multiple printers