(fix): Added a logrotate function to the crowdsec.go installer file#2873
Conversation
accessLog:
filePath: "/logs/traefik/access.log"
fields:
headers:
names:
User-Agent: keepFor me, honestly don't even need User-Agent as I mostly have whitelists contained against traefik's own routers. But my logs go back 2+ years and only sit with 185MB. What is the default access log look like for auto installs? |
Ahh, to be honest, I'm still learning what everything is. First time contributor here. So I can't exactly be sure if these additional fields are actually being used much, which is why I flagged it for review to kind of give a signal on what can we drop and what not on a default install settings with crowdsec, and maybe that can be addressed with a seperate PR from this. I'll try and take a look at the default access log though. Hope you understand, sorry. |
|
No worries. 🙂 Also responding from discord right now. One of the support but haven't checked what the default install recently ships with. |
Ohh coool. I was thinking of putting an introduction on Discord right after getting this merged. Umm soo, Should we wait for a response from someone else then? :) |
|
I can't touch the pr stuff so will have to wait for the others. :), Made a bot that lets me respond from discord and see everything from a glance. |
Got itt, thanks! (The bot sounds cool! :) ) |
|
@oschwartz10612 Can you please take a look at this whenever available? |
|
Thanks! |
Awesome! Thanks for the merge! There was a follow-up documentation PR for this too. DOCS PR -> fosrl/docs-v2#98 |
|
Thanks for the reminder! Merged into dev which can out out with the release
|
Add logrotate config for Traefik access logs when CrowdSec is installed
Fixes #2644
Documentation Update : fosrl/docs-v2#98
What and why
The default Pangolin install does not enable Traefik access logging.
When CrowdSec is selected during installation, the installer enables Traefik access logs (required for CrowdSec to detect threats).
These logs are written to:
config/traefik/logs/access.log(on the host)Without log rotation, this file grows indefinitely, which is the issue reported in #2644.
This change fixes the problem only in the CrowdSec installation path, keeping the default install unaffected.
What changed
File modified:
install/crowdsec.gosetupTraefikLogRotate()installCrowdsec()immediately after the directoryconfig/traefik/logs/is created./etc/logrotate.d/pangolin-traefikusing the absolute path to the access log (resolved from the install directory).Logrotate configuration written:
/opt/pangolin/config/traefik/logs/access.log { daily rotate 7 compress delaycompress missingok notifempty copytruncate }If the installer is not running as root, it skips writing the file and instead prints the full configuration to stdout (with the actual resolved path), allowing the user to set it up manually.
Testing
The generated config was validated directly with
logrotate:Observed behavior:
No changes were made to the default (non-CrowdSec) installation path as suggested by @oschwartz10612.
PS : Can someone please go through this comment and verify if a follow up PR like this is required where we are dropping the unused fields from crowdsec installation?