I create an Octoprint container to control my printer, and it works fine.
Now I want to have secure access to it from anywhere. To do this, I use HAProxy.
However, after authorization, HAProxy returns the StatusCode 503, and I can't fix that.
Here are the docker files and configuration file:
docker-compose.yml
version: "2.5"
services:
haproxy:
build:
context: .
dockerfile: haproxy/Dockerfile
container_name: haproxy
image: haproxy:latest
restart: always
volumes:
- haproxy_conf:/usr/local/etc/haproxy/
ports:
- 80:80
depends_on:
- octoprint
networks:
- haproxy_net
octoprint:
restart: unless-stopped
image: octoprint/octoprint
container_name: octoprint
ports:
- 5521:80
networks:
- haproxy_net
volumes:
- octoprint:/octoprint
volumes:
haproxy_conf:
octoprint:
networks:
haproxy_net:
driver: bridge
haproxy\haproxy.cfg
global
maxconn 4096
user haproxy
group haproxy
daemon
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 15m
timeout server 15m
frontend public
bind *:80 v4v6
default_backend octoprint
backend octoprint
http-request replace-path ^([^\ :]*)\ /(.*) \1\ /\2
option forwardfor
server octoprint1 octoprint:5521
acl AuthOkay http_auth(L1)
http-request auth realm octoprint if !AuthOkay
userlist L1
user UserName insecure-password Password
haproxy\Dockerfile
FROM haproxy:latest
COPY haproxy/haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
You're using configuration directives that are not supported in the old HAProxy 1.8 version bundled in Octopi.
Specifically
http-request replace-path
.replace-path
was introduced in HAproxy 2.1 or 2.2. So you'll need to upgrade it before your config will work.I've been hunting for pre-built haproxy 2.2+ binary for RPi's ARM architecture myself for a while now, but I think it's down to building it ourselves. I'm going to be trying for 2.4 sometime soon, since ARM build support exists in the HAproxy source.