I've been using Traefik for a little while and I want to set up protections like CrowdSec. The problem is that I just realized that in Traefik's logs, the ClientHost / ClientAddr doesn't match my IP address, but rather that of my Docker gateway. My Traefik's IP is 172.25.0.35 and the ClientHost values are 172.25.0.1. How can I fix this?
# Global setup
global:
sendAnonymousUsage: false
log:
level: INFO
format: common
api:
dashboard: true
insecure: true
# Set accessLog for fail2ban
accessLog:
filePath: "/var/log/traefik/traefik.log"
format: json
#filters:
# statusCodes:
# - "200"
# - "400-599"
#retryAttempts: true
#minDuration: "10ms"
# collect logs as in-memory buffer before writing into log file
bufferingSize: 0
fields:
headers:
defaultMode: drop # drop all headers per default
names:
User-Agent: keep # log user agent strings
# Set providers
providers:
file:
directory: "/etc/traefik/dynamic_config"
watch: true
docker:
exposedByDefault: false
network: traefik-net
allowEmptyServices: true
# Setup entrypoints
entrypoints:
## HTTP to HTTPs
webunsecure:
address: ":80"
http:
redirections:
entrypoint:
to: web
scheme: https
## HTTPS
web:
address: ":443"
http2:
maxConcurrentStreams: 50
# Metrics for prometheus
metrics:
address: ":8082"
# Certificats resolvers & TLS
certificatesresolvers:
letsencrypt:
acme:
storage: /etc/traefik/acme.json
#caServer: https://acme-staging-v02.api.letsencrypt.org/directory
email: xxx@xxx.fr
httpChallenge:
entryPoint: webunsecure
#dnschallenge:
#delayBeforeCheck: 0
#provider: infomaniak
#resolvers:
# - "1.1.1.1:53"
# - "8.8.8.8:53"
# Setups features (metrics)
metrics:
prometheus:
entryPoint: metrics
When I use Traefik on a VM connected to the Internet with it's own dedicated IP, I see my client IP in Traefik access log. Check simple Traefik example.
My best guess is you have a router in between (maybe a VM with NAT) or OMV's Docker is doing something to the network.