Skip to content

Traefik: keep the User-Agent header in the access log #8233

Description

@Mactosk

The Traefik static configuration is created with accessLog: {}. With this default Traefik drops all request headers, so the User-Agent field of every access log line is "-".

Why: log-based detection cannot use the User-Agent.

  • ns8-crowdsec installs crowdsecurity/base-http-scenarios, but http-bad-user-agent and the other User-Agent based scenarios never match.
  • External SIEMs (e.g. Wazuh) cannot detect scanners or Shellshock payloads in the User-Agent, nor ignore legitimate crawlers.

Purpose: give CrowdSec and SIEMs the User-Agent, without logging any other request header.

Proposed solution

Keep only the User-Agent request header in the access log; every other header stays dropped. Referer may contain tokens or OAuth codes, and Authorization/Cookie must never be logged.

accessLog:
  fields:
    headers:
      defaultMode: drop
      names:
        User-Agent: keep
  • create-module: new default.
  • update-module.d/15upgrade_v3: an idempotent step, like add_metrics, that only replaces the default accessLog: {}. A missing (disabled) or customized accessLog is left untouched.

Alternative solutions

  • An opt-in action, like set-trusted-proxies/get-trusted-proxies, also handled by restore-module.
  • Editing traefik.yaml by hand: it survives module updates, because 15upgrade_v3 reloads and rewrites the YAML keeping the keys, but it is lost on restore-module.

Additional context

Tested on an NS8 node on 2026-10-14 (NS8 Core 3.19.0, traefik module 4.2.1, Traefik 3.6.10), by editing traefik.yaml and restarting the module: the User-Agent appears in the access log lines, the Referer is still "-", and the routes answer as before. The only error at startup is the already existing core.defaultRuleSyntax deprecation. On 2026-10-15 the same node was updated to Core 3.23.0 (traefik module 4.2.1 → 4.2.4) and the hand-edited accessLog was kept, as expected from 15upgrade_v3.

The ns8-wazuh module and CrowdSec would both use the field (see the community discussion).

See also

Activity

  1. added theissue type on Oct 15, 2026
  2. moved this from ToDo to In Progress in NethServeron Oct 15, 2026
  3. self-assigned this
    on Oct 20, 2026
  4. removed their assignment
    on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

  • Status
    In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions