我正在尝试使用 docker 运行 haproxy。我按照这里的说明进行操作:
https://hub.docker.com/_/haproxy/
我能够构建 docker 镜像,但在尝试运行它之后。
使用
docker run -d --link another_container:another_container --name mc-ha -v haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro my_own_haproxy:latest
我收到此错误:
[ALERT] 298/054910 (1) : [haproxy.main()] No enabled listener found (check for 'bind' directives) ! Exiting.
我搜索了一下,发现的只有ha proxy的源码。
这是我的 haproxy.cfg
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL).
ssl-default-bind-ciphers kEECDH+aRSA+AES:kRSA+AES:+AES256:RC4-SHA:!kEDH:!LOW:!EXP:!MD5:!aNULL:!eNULL
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
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 esNodes
bind *:8091
mode http
default_backend srNodes
backend srNodes
mode http
balance roundrobin
option forwardfor
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
option httpchk HEAD / HTTP/1.1\r\nHost:localhost
server web01 0.0.0.0:10903/project/es check
编辑:顺便说一句,我还尝试将后端节点 url 更改为我的 docker 主机 ip。但仍然没有运气。
最佳答案
感谢@Michael 的评论。我能够解决这个问题。
首先,我从 dockerfile 中删除 haproxy 命令。然后我在容器内手动运行 haproxy 命令。
瞧!我的配置文件不是文件。它是一个目录。哈哈
问题出在我的 docker 命令 -v 中。
我把它改成完整路径
-v FULL_PATH/customhaproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg
关于proxy - haproxy/docker 未找到启用的监听器(检查 'bind' 指令)!退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33339332/