Using HAProxy to redirect, but not to load balance
-
While setting up the program OctoPrint to work on a Raspberry Pi and to include a 2nd instance of the program on that Pi, I came on instructions about what to do with HAProxy for creating aliases on my Pi. For instance, if I had multiple webcam streams, I could use HAProxy to create an alias. For example, http://octoprint.local/webcam2 would point to port 1020 on that system and http://octoprint.local/webcam3 would point to port 1030.
Can I use HAProxy in a similar way, as a pfSense plugin, to redirect traffic from one system on my LAN to another? For instance, say I have a Pi at 3dprint.local that controls one printer, and 3dprint2.local on another system, 3dprint3.local on another, and so on. Can I use HAProxy so 3dprint.local/prusa01 goes to 3dprint.local, and 3dprint.local/prusa02 goes to 3dprint2.local, and 3dprint.local/ender3 points to 3dprint3.local?
I know I can do this with the system hostnames, for instance, instead of 3dprint2.local, use prusa00.local, but there are reasons (in part how my memory works and what makes it easier for me, but other reasons), so I'd rather use a redirection. (Also, I'm interested in this as a use in other situations, too.)
Is it possible to use HAProxy this way?
-
@TangoOversway
For sure, you do this with HAproxy.But do the printers check the host name at all, or do they only simply listen on IP and port?
Means, if 3dprint3.local is awaiting this host name (I don't assume), you would have to rewrite it independently for each printer.For the rest you just need an ACL "path starts with" or "path matches", and actions for each to use the respective backend.
-
@viragomann said in Using HAProxy to redirect, but not to load balance:
But do the printers check the host name at all, or do they only simply listen on IP and port?
The printers are connected to the Pi with a USB cable. They don't deal with IP at all. What does deal with anything like that is the slicer when I use it to upload to OctoPrint to print, but that's something I expected to have to deal with.
Sounds like the configuration is pretty much the same as what I had to do on the Pi I was using for printing and shouldn't be too hard.
Thanks - and thank you for not going into why to just use the names I give each host instead!