[英]Configuring HAProxy in docker (503 Service Unavailable)
I create an Octoprint container to control my printer, and it works fine.我创建了一个 Octoprint 容器来控制我的打印机,它工作正常。 Now I want to have secure access to it from anywhere.现在我想从任何地方安全地访问它。 To do this, I use HAProxy.为此,我使用 HAProxy。
However, after authorization, HAProxy returns the StatusCode 503, and I can't fix that.但是,授权后,HAProxy 返回 StatusCode 503,我无法修复它。
Here are the docker files and configuration file:以下是 docker 文件和配置文件:
docker-compose.yml 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 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 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.您正在使用 Octopi 中捆绑的旧 HAProxy 1.8 版本不支持的配置指令。
Specifically http-request replace-path
.特别http-request replace-path
。 replace-path
was introduced in HAproxy 2.1 or 2.2.在 HAproxy 2.1 或 2.2 中引入了replace-path
。 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.一段时间以来,我一直在为 RPi 的 ARM 架构寻找预构建的 haproxy 2.2+ 二进制文件,但我认为这取决于我们自己构建它。 I'm going to be trying for 2.4 sometime soon, since ARM build support exists in the HAproxy source.我将很快尝试 2.4,因为 ARM 构建支持存在于 HAproxy 源中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.