For anyone who comes along and is trying to get haproxy to work with a redirect...
At the time I posted this, all of the documentation I could find tells you to do this:
backend octoprint
acl needs_scheme req.hdr_cnt(X-Scheme) eq 0
reqrep ^([^\ :]*)\ /octoprint/(.*) \1\ /\2
reqadd X-Scheme:\ https if needs_scheme { ssl_fc }
reqadd X-Scheme:\ http if needs_scheme !{ ssl_fc }
reqadd X-Script-Name:\ /octoprint
option forwardfor
server octoprint1 127.0.0.1:5000
errorfile 503 /etc/haproxy/errors/503-no-octoprint.http
There are also posts telling you that because haproxy has been updated, you have to replace reqrep/reqadd => http-request.
Perhaps you'll start off like I did, trying to modify the latest default provided by OctoPi
backend octoprint
acl needs_scheme req.hdr_cnt(X-Scheme) eq 0
http-request replace-path ^([^\ :]*)\ /(.*) \1\ /\2
http-request add-header X-Scheme https if needs_scheme { ssl_fc }
http-request add-header X-Scheme http if needs_scheme !{ ssl_fc }
option forwardfor
server octoprint1 127.0.0.1:5000
errorfile 503 /etc/haproxy/errors/503-no-octoprint.http
Perhaps you'll be like me, and naively change it to:
http-request replace-path ^([^\ :]*)\ octoprint/(.*) \1\ /\2
It'll connect to the OctoPrint login page, but it'll just loop at the login page. The proxy test page will show proper server values, but a blank space for all the client values. The help will send you here, to this page, which as of the time of writing was outdated.
If you know/learn how to read the haproxy log file, you'll see the GET requests don't have the server:port number prepended, and that you've written your replace-path incorrectly. Perhaps because you were like me, and had no idea what you were doing.
Here's a version that works for me, which perhaps might be helpful to someone:
backend octoprint
acl needs_scheme req.hdr_cnt(X-Scheme) eq 0
http-request replace-path /octoprint/(.*) /\1
http-request add-header X-Script-Name /octoprint
http-request add-header X-Scheme https if needs_scheme { ssl_fc }
http-request add-header X-Scheme http if needs_scheme !{ ssl_fc }
option forwardfor
server octoprint1 127.0.0.1:5000
errorfile 503 /etc/haproxy/errors/503-no-octoprint.http