Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
Paolo Asperti | 5069b7fc29 | |
Paolo Asperti | e6977298f4 | |
Paolo Asperti | 130cd41438 | |
Paolo Asperti | e91455f8e1 | |
Paolo Asperti | dcafe9347b |
11
Dockerfile
11
Dockerfile
|
@ -1,4 +1,4 @@
|
|||
FROM alpine:3.15
|
||||
FROM alpine:3.18
|
||||
|
||||
RUN \
|
||||
apk -U add rsyslog rsyslog-mmutf8fix
|
||||
|
@ -8,8 +8,11 @@ COPY run.sh /
|
|||
EXPOSE 514/tcp
|
||||
EXPOSE 514/udp
|
||||
|
||||
ENV TARGET_HOST
|
||||
ENV TARGET_PROTO
|
||||
ENV TARGET_PORT
|
||||
ENV TARGET_HOST="127.0.0.1"
|
||||
ENV TARGET_PROTO="tcp"
|
||||
ENV TARGET_PORT="514"
|
||||
ENV DEBUG="0"
|
||||
|
||||
VOLUME [ "/extraconfig" ]
|
||||
|
||||
ENTRYPOINT ["/bin/sh", "/run.sh"]
|
15
README.md
15
README.md
|
@ -15,10 +15,15 @@ docker build . -t docker.asperti.com/paspo/syslog-forwarder
|
|||
## environment
|
||||
|
||||
Variable | Default | Description
|
||||
--------------|-----------|---------------------------
|
||||
--------------|-----------|----------------------------------------------------
|
||||
TARGET_HOST | 127.0.0.1 | target server IP/hostname
|
||||
TARGET_PROTO | tcp | `tcp` or `udp`
|
||||
TARGET_PORT | 514 | target server syslog port
|
||||
DEBUG | 0 | if != 0, every received log line is shown on stdout
|
||||
|
||||
## extra config files
|
||||
|
||||
You can add some custom config file, by mounting the `/extraconfig` directory. Any file ending in `.conf` placed here will be added to rsyslog configuration.
|
||||
|
||||
## run
|
||||
|
||||
|
@ -46,3 +51,11 @@ services:
|
|||
- TARGET_PROTO=tcp
|
||||
- TARGET_PORT=1514
|
||||
```
|
||||
|
||||
## testing
|
||||
|
||||
If you need a log source for testing, you can use the `logger` command:
|
||||
|
||||
```bash
|
||||
logger --server my.logserver.com --tcp --rfc3164 --priority 3 --port 514 "ciao"
|
||||
```
|
||||
|
|
16
run.sh
16
run.sh
|
@ -9,6 +9,9 @@ TARGET_PROTO=${TARGET_PROTO:-tcp}
|
|||
# 514 is the common default
|
||||
TARGET_PORT=${TARGET_PORT:-514}
|
||||
|
||||
# DEBUG MODE ENABLED if != 0
|
||||
DEBUG=${DEBUG:-0}
|
||||
|
||||
cat >/etc/rsyslog.conf <<EOF
|
||||
\$WorkDirectory /var/lib/rsyslog
|
||||
|
||||
|
@ -34,6 +37,13 @@ if (\$hostname == '') then set \$!hostname = \$fromhost;
|
|||
|
||||
EOF
|
||||
|
||||
if [ "${DEBUG}" != "0" ] ; then
|
||||
cat >>/etc/rsyslog.conf <<EOF
|
||||
module(load="omstdout")
|
||||
action(type="omstdout")
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ "${TARGET_PROTO}" = "udp" ] ; then
|
||||
cat >>/etc/rsyslog.conf <<EOF
|
||||
action(type="omfwd" protocol="udp" target="${TARGET_HOST}" port="${TARGET_PORT}" Template="RSYSLOG_SyslogRFC5424Format" )
|
||||
|
@ -44,4 +54,10 @@ action(type="omfwd" protocol="tcp" target="${TARGET_HOST}" port="${TARGET_PORT}"
|
|||
EOF
|
||||
fi
|
||||
|
||||
# extra config
|
||||
mkdir -p /extraconfig
|
||||
cat >>/etc/rsyslog.conf <<EOF
|
||||
$IncludeConfig /etc/rsyslog.d/*.conf
|
||||
EOF
|
||||
|
||||
/usr/sbin/rsyslogd -nf /etc/rsyslog.conf
|
||||
|
|
Loading…
Reference in New Issue