Requests coming to my Traefik container all have dockers 172.18.0.1 ip. How can i get the real ip of client?

Hello, i am running docker rootless 27.5.1.

  • i have traefik reverse proxy in a container and host is ubuntu server
  • problem is every request that comes in my r proxy has the ip 172.18.0.1 which is that of docker router

How can i solve this i want to get real ip of client because i need it for middlewares in traefik but also without compromising security?
This is such a big problem online and i still didnt find a real solution to this.

Things i tried:

  • macvelan network
  • network mode host + publishing ports of container
  • different configurations in traefik for getting info from headers.

Please ask me if you need more info from me.

docker-compose:

services:
    reverse-proxy:
        image: traefik:v3.3
        restart: always
        container_name: traefik
        labels:
            - traefik.enable=false  # Prevents Traefik from discovering itself
        ports:
            - "80:80"     # http
            - "443:443"   # https
            - "8080:8080" # dashboard
        volumes:
            - /run/user/1000/docker.sock:/var/run/docker.sock
            - ./conf/traefik_config/traefik.yml:/etc/traefik/traefik.yml
            - ./conf/certs:/etc/traefik/certs
            - ./conf/dynamic:/etc/traefik/dynamic/
            - ./conf/letsencrypt/:/etc/letsencrypt/

Hey can somebody help me? i have been scratching my head on this for days.

If you still have the issue, it is probably because of rootless mode. See the Networking Errors section here in the documentation:

https://docs.docker.com/engine/security/rootless/#networking-errors

It shows that source IP is not propagated when using the default network. You can change the port driver, but it will also be slower.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.