首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在haproxy中获取日志:1.5-高山Docker容器

如何在haproxy中获取日志:1.5-高山Docker容器
EN

Stack Overflow用户
提问于 2017-05-23 22:35:53
回答 2查看 4.8K关注 0票数 3

从haproxy构建haproxy容器:1.5-alpine

(https://github.com/docker-library/haproxy/blob/1848d2933afbefd0e0a068dc7b5a753ab7842e6c/1.5/alpine/Dockerfile)

haproxy容器一开始很好,但是我如何实现详细的haproxy日志记录并将其定向到stdout。

我的haproxy配置是

代码语言:javascript
复制
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

    tune.ssl.default-dh-param 2048
    # Default SSL material locations
    #ca-base /etc/ssl/certs
    #crt-base /etc/ssl/private

    ssl-default-bind-options no-sslv3
    ssl-default-bind-ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM
enter code here

defaults
    log global
    mode  http
    option  httplog
    option  dontlognull

    # fixed configuration by Benson
    option  http-keep-alive
    timeout http-keep-alive 5m
    timeout http-request 5s
    timeout connect 300s
    timeout client  300s
    timeout server  300s
    timeout check   300s

    #old configurations causing connection timeouts
    #timeout connect 5000
    #timeout client  50000
    #timeout server  50000

    errorfile 400 /usr/local/etc/haproxy/errors/400.http
    errorfile 403 /usr/local/etc/haproxy/errors/403.http
    errorfile 408 /usr/local/etc/haproxy/errors/408.http
    errorfile 500 /usr/local/etc/haproxy/errors/500.http
    errorfile 502 /usr/local/etc/haproxy/errors/502.http
    errorfile 503 /usr/local/etc/haproxy/errors/503.http
    errorfile 504 /usr/local/etc/haproxy/errors/504.http
    balance roundrobin
    option httpchk

我尝试了通过docker entrypoint.sh中的以下命令将日志定向到标准输出的选项

"/bin/sh -c /sbin/syslogd -O /dev/stdout“

代码语言:javascript
复制
#!/bin/sh
set -e

# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
        set -- haproxy "$@"
fi

if [ "$1" = 'haproxy' ]; then
        # if the user wants "haproxy", let's use "haproxy-systemd-wrapper" instead so we can have proper reloadability implemented by upstream
        /bin/sh -c /sbin/syslogd -O /dev/stdout
        shift # "haproxy"
        set -- "$(which haproxy-systemd-wrapper)" -p /run/haproxy.pid "$@"
fi

exec "$@"

然而,当我通过haproxy浏览应用程序时,没有日志被注册,尽管它提供了良好的服务。

我想知道如何通过高山haproxy容器内的haproxy获得详细的日志记录。

EN

Stack Overflow用户

发布于 2018-02-24 07:00:16

您需要将/dev/log从主机传递到容器中,然后从主机端读取日志!haproxy的作者反对将日志记录到stdout (出于性能原因),因此除了我所描述的之外(或者在pod中的另一个容器中运行syslog守护进程),您可以做的并不多。

票数 3
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44137797

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档