crazy-max/docker-fail2ban

fail2ban logs

Closed this issue · 6 comments

I moved to your image from a previous docker implementation and before that from fail2ban installed on the host. Much prefer running it in docker.

However I had a couple of scripts running which parsed the fail2ban logs and performed actions when certain events occurred (e.g. triggered slack and pushbullet notifications to suppliment the emails). Typically the logs get written to /var/log/fail2ban.log.

Is there any way to write the fail2ban logs to a file with this image?

Did you try to mount /var/log/fail2ban.log to the host system?

I'm already mounting -v /var/log:/var/log to enable fail2ban to access various logs so unless I'm mistaken I should already see the fail2ban.log if it is being written.

@danteali Today fail2ban logs on this image are forced to stdout but I could set this up.

That would be great, looks like it would be relatively straightforward to add a new optional env var (e.g. $F2B_LOG_LOCATION) which would allow us to set the path for logging to a file if we needed to. I would do a PR myself but I'm not really familiar with using git repos (something I need to learn!).

For the time being I'll try copying fail2ban.conf locally and changing it manually then mounting at container startup.

Thanks for all your work on this.

@danteali You can now use F2B_LOG_TARGET to change log target. You can use /data/failban.log to keep log persisted for example.

Awesome! Thanks!