techno-tim / launchpad

A collection of quick starters for ansible, kubernetes, docker, linux, windows, and more. Great for HomeLabs!
https://technotim.live
1.43k stars 474 forks source link

Traefik ipwhitelist middleware not working #6

Closed fanpero87 closed 2 years ago

fanpero87 commented 2 years ago

Hello, I was following your "2 Factor Auth and Single Sign on with Authelia" video and I have an issue with the whitelist middleware on traefik. for some reason is not quite working.

here is the section of the config.yml file. In here, I'm not sure if you need some indentation on the IP field.

default-whitelist:
      ipWhiteList:
        sourceRange:
        - "98.143.96.201/32" # you have it like this
          - "98.143.96.201/32" # I think it should be like this

It doesn't matter from what IP I try to connect, I always reach both traefik and portainer portals.

I even added these two lines on both docker-compose files (traefik and portainer) and recreate the containers but nothing changed.

labels:
...
- "traefik.http.routers.traefik.middlewares=default-whitelist"
- "traefik.http.middlewares.default-whitelist.ipwhitelist.sourcerange=98.143.96.201/32"

Does the order of the lines matter? I tried at the end of the labels section, then right after you define the host and set the login credentials. Made no difference.

I also tried to add the middleware directly on an external service that I'm running but nothing, it doesn't work. I can reach the site from any IP. Here is a section of the config.yml file.

http:
  routers:
    rancher:
      entryPoints:
        - "https"
      rule: "Host(`rancher.example.com`)"
      middlewares:
        - authelia
        - default-headers
        - default-whitelist
      tls: {}
      service: rancher

Do we need both the labels and the middleware set? what else can I try to make it work?

Thanks.