Traefik ipWhiteList middleware is not working(


I'm trying to follow this:

# grep ipwhitelist docker-compose.override.yml
      - "traefik.http.middlewares.whoami@docker.ipwhitelist.sourcerange=X.X.X.X"

and even though I did specified sourcerange, I'm able to access resource from anywhere..

My environment:

# docker exec -it traefik uname -a
Linux ae81ad8c61b7 6.1.0-11-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.38-4 (2023-08-08) x86_64 Linux
# docker exec -it traefik traefik version
Version:      2.10.4
Codename:     saintmarcelin
Go version:   go1.20.6
Built:        2023-07-24T16:29:02Z
OS/Arch:      linux/amd64

Please advise.
Thank you in advance

test from different source ip:

# curl https://whoami.X.Y.Z
Hostname: 146fcf2d3665
GET / HTTP/1.1
Host: whoami.X.Y.Z
User-Agent: curl/7.88.1
Accept: */*
Accept-Encoding: gzip
X-Forwarded-For: Y.Y.Y.Y
X-Forwarded-Host: whoami.X.Y.Z
X-Forwarded-Port: 443
X-Forwarded-Proto: https
X-Forwarded-Server: ae81ad8c61b7
X-Real-Ip: Y.Y.Y.Y


You need to declare the middleware and assign the middleware to the router, see doc example.

you're right, I was missing applying the middleware to the router, similar to this:

    # Apply the middleware named `foo-add-prefix` to the router named `router1`
    - "traefik.http.routers.router1.middlewares=foo-add-prefix@docker"


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