IpWhitelist : Adding IP no hot reloaded?

Hi,

I added ipwhitelist middleware on dynamic.yml file. It's work great.
But i have to add some new IPs on source range list sometime and it's seems that i have to down/up again traefik docker compose file.
is there no hot reload on middlewares with dynamic file ?

Maybe i add a wrong settings...

Traefik v2.5.5
docker-compose.file :

volumes:
            - /var/run/docker.sock:/var/run/docker.sock:ro
            - ./conf/traefik.yml:/etc/traefik/traefik.yml
            - ./conf/dynamic.yml:/etc/traefik/dynamic.yml

dynamic.yml :

http:
    middlewares:
        ##other middlewares
        whitelist:
            ipWhiteList:
                sourceRange:
                    - "x.x.x.x/32"
                    - "y.y.y.y/32"
                    - "w.w.w.w"
##other stuff

traefik static config traefik.yml :

providers:
    docker:
        endpoint: "unix:///var/run/docker.sock"
        exposedByDefault: false
        watch: true

    file:
        filename: /etc/traefik/dynamic.yml
        watch: true

docker-compose label for a service :

labels:
    ##other traefik labels
    - traefik.http.routers.my-service.middlewares=whitelist@file

Thanks for your answer.

Bye

There are a lot of issues with the file.filename option. In most cases, those issues are solved by using the file.directory.

To solve your issues, you can update the docker-compose, to be like:

volumes:
            - /var/run/docker.sock:/var/run/docker.sock:ro
            - ./conf/traefik.yml:/etc/traefik/traefik.yml
            - ./conf/dynamic.yml:/etc/traefik/dynamic/dynamic.yml

and your traefik static configuration:

providers:
    file:
        directory: /etc/traefik/dynamic/
        watch: true

This way, each time you will update the ./conf/dynamic.yml file, traefik will reload it's dynamic configuration.

Hi @tommoulard,

Thanks for the reply.

I have update the compose and static files like you said, but i have the same problem...
No matter if i add or remove IPs in dynamic file, whitelist will not be hot reloaded :cry:

Any others suggestions ?

Docker v20.10.12
Docker-compose v1.29.2

Thanks

More infos :

I could see inside the traefik container that my changes in dynamic file are updated.
I try with rootless docker and i have the same issue

thanks

OH i figure it out !
As @tommoulard suggest replace "file.filename" by "file.directory" in static file

providers:
    file:
        directory: /etc/traefik/dynamic/
        watch: true

But also need a change in docker-compose file :

volumes:
            - /var/run/docker.sock:/var/run/docker.sock:ro
            - ./conf/traefik.yml:/etc/traefik/traefik.yml
            - ./conf/dynamic:/etc/traefik/dynamic  <!--- this works 
1 Like

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