Forward Rela Traefik IP and Header Logs

Internet networking basics:

A TCP connection will always have a source and destination, which will always be the IPs of the machines. If you want to know the IPs of previous machines, you need a workaround.

On TCP leaves there is ProxyProtocol, which will add the original IP in the data stream before the real data. This needs to be enabled on sender side (load balancer) and receiver side (Traefik). This can also be enabled between Traefik and target service.

On http level, you can just use the http headers. Regular target services will accept X-Forwarded-* headers and work with those.

X-Forwarded-For might contain multiple IPs chained if the request has multiple http hops. X-Real-Ip usually just has the first client IP (browser).


Geolocation always needs an external service via middleware/plugin.

You can enable Traefik access log in JSON format for a wealth of information.