[Sub-issue #80-C]: Traefik X-Request-Id Middleware #83

Closed
opened 2026-02-03 02:18:48 +00:00 by egullickson · 0 comments
Owner

Parent Issue

Refs #80 - Unified Debug Logging System

Scope

Configure Traefik to generate/forward X-Request-Id headers for request correlation.

Files to Modify

  • config/traefik/dynamic/middleware.yml - Add x-request-id middleware

Implementation Details

Add to middleware.yml:

http:
  middlewares:
    # Request ID generation/forwarding
    x-request-id:
      headers:
        customRequestHeaders:
          X-Request-Id: "{{uuid}}"
        # Note: Traefik v3 doesn't have native UUID generation
        # Alternative: Use plugin or rely on backend generation

Alternative approach (if Traefik lacks UUID generation):

  • Backend generates UUID if X-Request-Id header missing
  • Traefik forwards existing X-Request-Id headers
  • Add X-Request-Id to accessLog fields

Update middleware chains:

    api-chain:
      chain:
        middlewares:
          - compression
          - security-headers-strict
          - cors
          - rate-limit
          - api-auth
          - retry-policy
          # x-request-id handled by backend if not natively supported

Ensure access logs include request ID:

accessLog:
  format: json
  fields:
    headers:
      names:
        X-Request-Id: keep

Acceptance Criteria

  • X-Request-Id header present on all API requests
  • Header forwarded if already present, generated if missing
  • Access logs include X-Request-Id field
  • Works with api-chain and platform-chain

Dependencies

None - can be executed in parallel with #80-A and #80-E

Milestone

Milestone 1: Foundation

## Parent Issue Refs #80 - Unified Debug Logging System ## Scope Configure Traefik to generate/forward X-Request-Id headers for request correlation. ## Files to Modify - `config/traefik/dynamic/middleware.yml` - Add x-request-id middleware ## Implementation Details Add to middleware.yml: ```yaml http: middlewares: # Request ID generation/forwarding x-request-id: headers: customRequestHeaders: X-Request-Id: "{{uuid}}" # Note: Traefik v3 doesn't have native UUID generation # Alternative: Use plugin or rely on backend generation ``` **Alternative approach** (if Traefik lacks UUID generation): - Backend generates UUID if X-Request-Id header missing - Traefik forwards existing X-Request-Id headers - Add X-Request-Id to accessLog fields Update middleware chains: ```yaml api-chain: chain: middlewares: - compression - security-headers-strict - cors - rate-limit - api-auth - retry-policy # x-request-id handled by backend if not natively supported ``` Ensure access logs include request ID: ```yaml accessLog: format: json fields: headers: names: X-Request-Id: keep ``` ## Acceptance Criteria - [ ] X-Request-Id header present on all API requests - [ ] Header forwarded if already present, generated if missing - [ ] Access logs include X-Request-Id field - [ ] Works with api-chain and platform-chain ## Dependencies None - can be executed in parallel with #80-A and #80-E ## Milestone Milestone 1: Foundation
egullickson added the
status
backlog
type
chore
labels 2026-02-03 02:19:39 +00:00
egullickson added
status
in-progress
and removed
status
backlog
labels 2026-02-04 01:40:31 +00:00
egullickson added
status
review
and removed
status
in-progress
labels 2026-02-04 01:41:41 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: egullickson/motovaultpro#83