# How can I combine middlewares?

**URL:** <https://community.traefik.io/t/how-can-i-combine-middlewares/27707>\
**Category:** Traefik v3 (latest)\
**Tags:** file, docker, middleware\
**Created:** [June 9, 2025, 7:10pm UTC](https://community.traefik.io/t/how-can-i-combine-middlewares/27707 "2025-06-09T19:10:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![crewdk](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/crewdk/32/10455_2.png) [@crewdk](https://community.traefik.io/u/crewdk)\
**Post date:** [June 9, 2025, 7:10pm UTC](https://community.traefik.io/t/how-can-i-combine-middlewares/27707/1 "2025-06-09T19:10:08Z")

</div>

Hi, I'm trying to combine a middleware/plugin for Cloudflare to pass real client IPs to services behind Traefik (GitHub: BetterCorp/cloudflarewarp) with a middleware for filtering allowed IPs (whitelist). Each middleware works fine on its own, but when I use them together, the Cloudflare plugin fails to pass the real client IP to the whitelist middleware. I've tried using middleware chains, but it hasn't helped.

Currently, my middleware configuration looks like this:

/data/custom/cloudflare.yml

```auto
http:
  middlewares:
    my-cloudflarewarp:
      plugin:
        cloudflarewarp:
          disableDefault: false

```

/data/custom/whips.yml

```auto
http:
  middlewares:
    whitelist:
      ipWhiteList:
        sourceRange:
          - "192.168.1.0/24"
          - "1.2.3.4/32"
          - "4.5.6.7/32"
          - "3.4.5.6/32"

```

/cf-whips-chain.yml

```auto
http:
  middlewares:
    cf-then-whitelist:
      chain:
        middlewares:
          - my-cloudflarewarp@file
          - whitelist@file

```

and service I want to make to work /data/custom/bnb.yml

```auto
http:
  routers:
    bnb:
      rule: "Host(`bnb.hostname.ru`)"
      service: bnb-web-service
      middlewares:
        - cf-then-whitelist@file

  services:
    bnb-web-service:
      loadBalancer:
        servers:
          - url: http://192.168.1.33:88

```

---

<div class="post-metadata">

**Author:** ![crewdk](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/crewdk/32/10455_2.png) [@crewdk](https://community.traefik.io/u/crewdk)\
**Post date:** [June 12, 2025, 10:26am UTC](https://community.traefik.io/t/how-can-i-combine-middlewares/27707/2 "2025-06-12T10:26:37Z")

</div>

Never mind. Just took other plugin.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/b/bd81ebdb578656e76e56ff3cc3eed021d3ba132d.png) [@system](https://community.traefik.io/u/system)\
**Post date:** [June 15, 2025, 10:26am UTC](https://community.traefik.io/t/how-can-i-combine-middlewares/27707/3 "2025-06-15T10:26:40Z")

</div>

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