# IPwhitelist middleware errors

**URL:** <https://community.traefik.io/t/ipwhitelist-middleware-errors/16612>\
**Category:** Traefik v2\
**Tags:** middleware\
**Created:** [November 28, 2022, 12:45pm UTC](https://community.traefik.io/t/ipwhitelist-middleware-errors/16612 "2022-11-28T12:45:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lewisd19](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@lewisd19](https://community.traefik.io/u/lewisd19)\
**Post date:** [November 28, 2022, 12:45pm UTC](https://community.traefik.io/t/ipwhitelist-middleware-errors/16612/1 "2022-11-28T12:45:05Z")

</div>

Hello all,

Please pardon me, this is my very first post in here. Ive been tearing my hair out trying to get the IPwhitelist middleware working. Ive searched and I see the previous posts on this and Ive got mine setup properly (i believe) according to the documentation but I am seeing in the logs:

```auto
"Rejecting IP : empty IP address" middlewareName=middlewares-internalonly@file middlewareType=IPWhiteLister

```

Here is my middlewares.yml config

```auto
 #Prevent external access
    middlewares-internalonly:
      IpWhiteList:
        sourceRange:
          - "172.168.90.0/24" #Traefik Network
          - "172.168.91.0/24" #Socket Proxy Network
          - "172.28.0.0/24" #Docker LAN Network
          - "10.0.0.0/8"
          - "192.168.128.0/24"
          - "172.16.0.0/12"
          - "10.20.10.0/24" #Private LAN Addresses
            #- "100.64.0.0/10" #Tailscale Network

        ipStrategy:
                #depth: 2
          excludedIPs:
            - "103.21.244.0/22" #Start Cloudflare Proxies
            - "103.22.200.0/22"
            - "103.31.4.0/22"
            - "104.16.0.0/13"
            - "104.24.0.0/14"
            - "108.162.192.0/18"
            - "131.0.72.0/22"
            - "141.101.64.0/18"
            - "162.158.0.0/15"
            - "172.64.0.0/13"
            - "173.245.48.0/20"
            - "188.114.96.0/20"
            - "190.93.240.0/20"
            - "197.234.240.0/22"
            - "198.41.128.0/17" #End Cloudflare Proxies

```

and my middlewares-chains.yml

```auto
http:
  middlewares:
    chain-no-auth:
      chain:
        middlewares:
                #- middlewares-traefik-bouncer
          - middlewares-rate-limit
          - middlewares-https-redirectscheme
          - middlewares-secure-headers
          - middlewares-compress

    chain-basic-auth:
      chain:
        middlewares:
                #- middlewares-traefik-bouncer
          - middlewares-rate-limit
          - middlewares-https-redirectscheme
          - middlewares-secure-headers
          - middlewares-basic-auth
          - middlewares-compress

    chain-nextcloud:
      chain:
        middlewares:
          - middlewares-rate-limit
          - nextcloud-middlewares-secure-headers
          - nextcloud-redirect

    chain-oauth:
      chain:
        middlewares:
                #- middlewares-traefik-bouncer
          - middlewares-rate-limit
          - middlewares-https-redirectscheme
          - middlewares-secure-headers
          - middlewares-oauth
          - middlewares-compress

     ## Internal Access Only
    chain-internal:
      chain:
        middlewares:
                #- middlewares-rate-limit
          - middlewares-secure-headers
             #- middlewares-robots-noindex
          - middlewares-internalonly

```

I am using Traefikv2.8. Can anyone help me understand what I'm missing?

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [November 28, 2022, 3:32pm UTC](https://community.traefik.io/t/ipwhitelist-middleware-errors/16612/2 "2022-11-28T15:32:54Z")

</div>

Why do you have IPs allowed and forbidden? Shouldn’t you decide for a single strategy?

---

<div class="post-metadata">

**Author:** ![jur3](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@jur3](https://community.traefik.io/u/jur3)\
**Post date:** [November 28, 2023, 12:16pm UTC](https://community.traefik.io/t/ipwhitelist-middleware-errors/16612/3 "2023-11-28T12:16:10Z")

</div>

I had the same issue and figured out that I had the wrong `depth` setting on the middleware.

If the number of Client IPs in X-forwarded-from request header is less than the `depth` setting on the middleware IpWhitelist you will get and empty Client IP in the middleware.

Traefik documentation was updated ... [Traefik HTTP Middlewares IPWhiteList - Traefik](https://doc.traefik.io/traefik/middlewares/http/ipwhitelist/#ipstrategydepth)
