Whitelist middleware, with custom header, or access headers values from header middleware

Hi guys, have a quick question, just migrated to v2. I’m running traefik with k8s on GC with load balancer, and I’m using claudflare. So because of claudflare, x-forwarded-for always includes only claudflare IP addresses when traefik service is configured with externalTrafficPolicy: Local . And because of that whitelist middleware is useless. So question is, is it possible to use whitelist middleware with any other header besides x-forwarded-for ? (claudflare provides real-ip in cf-connecting-ip ). Or is it possible to access request header values from headers middleware? in that case I can do basic mapping something like:

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: whitelist-1
spec:
  headers:
    customRequestHeaders:
      x-forwarded-for: ":cf-connecting-ip"
  ipWhiteList:
    ipStrategy:
      depth: 1
    sourceRange:
    - *******/32
    - *******/32
    - *******/32

Any help is appreciated, thanks!

3 Likes