[英]Configuring HAProxy in docker (503 Service Unavailable)
我创建了一个 Octoprint 容器来控制我的打印机,它工作正常。 现在我想从任何地方安全地访问它。 为此,我使用 HAProxy。
但是,授权后,HAProxy 返回 StatusCode 503,我无法修复它。
以下是 docker 文件和配置文件:
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
您正在使用 Octopi 中捆绑的旧 HAProxy 1.8 版本不支持的配置指令。
特别http-request replace-path
。 在 HAproxy 2.1 或 2.2 中引入了replace-path
。 因此,您需要在配置生效之前对其进行升级。
一段时间以来,我一直在为 RPi 的 ARM 架构寻找预构建的 haproxy 2.2+ 二进制文件,但我认为这取决于我们自己构建它。 我将很快尝试 2.4,因为 ARM 构建支持存在于 HAproxy 源中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.