Sign inSign up

vladimirjk/haproxy-docker-logs

By vladimirjk

•Updated almost 8 years ago

Haproxy setup with logs to stdout and stderr

Image
0

93

vladimirjk/haproxy-docker-logs repository overview

⁠Haproxy docker logging

Haproxy logging to stdout based on rsyslog for haproxy logs and separate error stream for stderr based on errorfile functional.

⁠Dockerfile

FROM haproxy:1.8-alpine

RUN set -exo pipefail \
    && apk add --no-cache \
        rsyslog \
    && apk del syslog-ng \
    && mkdir -p /etc/rsyslog.d \
    && touch /var/log/haproxy.log \
    && ln -sf /dev/stdout /var/log/haproxy.log \
    && ln -sf /dev/stderr /var/log/haproxy-error.log

COPY entrypoint.sh /
COPY rsyslog.conf /etc/rsyslog.d/

ENTRYPOINT ["/entrypoint.sh"]

CMD ["-f", "/usr/local/etc/haproxy/haproxy.cfg"]

⁠Usage

  1. Deploy docker image as a normal haproxy container. Docker-compose example below:
version: '2'
services:
  haproxy:
    image: vladimirjk/haproxy-docker-logs:1.8-alpine
    volumes:
      - ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
    ports:
      - 80:80
      - 443:443
    restart: always
  1. Add logging to your haproxy.cfg file in next way (one row to global section and second to defaults):
...
global
...
                log                       127.0.0.1       local0  info
                log                       127.0.0.1       local1  err
...
defaults
...
                log                       global
...

Tag summary

Content type

Image

Digest

Size

10.6 MB

Last updated

almost 8 years ago

docker pull vladimirjk/haproxy-docker-logs:1.8-alpine