我试着在码头上运行哈代尔,但不起作用。
我所做的是:
FROM haproxy:2.3
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfgglobal
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
stats timeout 30s
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 10s
timeout client 60s
timeout server 60s
# errorfile 400 /etc/haproxy/errors/400.http
# errorfile 403 /etc/haproxy/errors/403.http
# errorfile 408 /etc/haproxy/errors/408.http
# errorfile 500 /etc/haproxy/errors/500.http
# errorfile 502 /etc/haproxy/errors/502.http
# errorfile 503 /etc/haproxy/errors/503.http
# errorfile 504 /etc/haproxy/errors/504.http
frontend https_in
mode tcp
option tcplog
bind *:443
acl tls req.ssl_hello_type 1
tcp-request inspect-delay 5s
tcp-request content accept if tls
acl host_server1 req.ssl_sni -i my1stdomain.com
acl host_server2 req.ssl_sni -i my2nddomain.com
use_backend https_Server if host_server1
use_backend https_NUC if host_server2
backend https_Server
mode tcp
# option tcplog
option ssl-hello-chk
server Server 10.0.0.10:443
backend https_NUC
mode tcp
# option tcplog
option ssl-hello-chk
server NUC 10.0.0.40:443my1stdomain.com的SSL端口443指向LAN 10.0.0.10,将my2nddomain.com的端口指向IP 10.0.0.40docker build -t my-haproxy .结果:
Sending build context to Docker daemon 4.096kB
Step 1/2 : FROM haproxy:2.3
---> 397cf3d55fac
Step 2/2 : COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
---> Using cache
---> a5cc1ff3c0c6
Successfully built a5cc1ff3c0c6
Successfully tagged my-haproxy:latest然后,我测试了配置:
docker run -it --rm --name haproxy-syntax-check my-haproxy haproxy -c -f /usr/local/etc/haproxy/haproxy.cfg
Configuration file is valid然后,我试着运行它:
docker run -d --name haproxy --restart=always -p 10.0.0.44:443:443/tcp my-haproxy
a253dbce7341e454353e9a2b4278e22ae8172ed106aeec7但是,当我运行docker ps时,我发现它并没有真正运行:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a253dbce7341 my-haproxy "docker-entrypoint.s…" About a minute ago Restarting (1) 12 seconds ago haproxy有什么建议吗?
发布于 2021-05-16 10:37:11
与其总是重新启动它,不如检查这个容器的故障日志。您可以从命令中删除-d标志,以便在前台运行此容器,以便在stdout上获得日志:
docker run --name haproxy --restart=always -p 10.0.0.44:443:443/tcp my-haproxy我用你的haproxy.cfg来检查这个问题。我在容器日志中发现了以下两个问题:
/var/lib/haproxy,但是这个目录不能由非根用户创建。因此,您可以显式地创建它并将所有权更改为haproxy用户。stats socket /run/haproxy/admin.sock命令中,需要创建/run/haproxy目录。因此,您的Dockerfile应该像这样进行更新,以使其工作:
FROM haproxy:2.3
RUN mkdir --parents /var/lib/haproxy && chown -R haproxy:haproxy /var/lib/haproxy
RUN mkdir /run/haproxy
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfghttps://serverfault.com/questions/1065786
复制相似问题