My requirement is to allow only specific IP addresses from the internet to be allowed through, however when applying the whitelist any IP is allowed to pass through, where am I going wrong?
This is my whitelist middleware line where I have explicitly set it to reject all internet traffic: - "traefik.http.middlewares.reverse-proxy.ipwhitelist.sourcerange=192.168.1.1"
However all internet traffic is being passed, what am I doing wrong?
This is my docker-compose.yml file:
version: '3'
services:
reverse-proxy:
# The official v2 Traefik docker image
image: traefik:v2.4.9
restart: unless-stopped
# Enables the web UI and tells Traefik to listen to docker
command:
- "--log.level=DEBUG"
- "--accesslog=true"
- "--accesslog.filepath=/var/log/traefik/access.log"
- --accesslog.bufferingsize=100
- "--api.insecure=false"
- "--providers.docker"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.myresolver.acme.tlschallenge=true"
- "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web"
# Comment out the next line to use production
# - "--certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
- "--certificatesresolvers.myresolver.acme.email=xx@xx.xx"
- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
- "traefik.http.middlewares.reverse-proxy.ipwhitelist.sourcerange=192.168.1.1"
ports:
# The HTTP port
- "80:80"
- "443:443"
# The Web UI (enabled by --api.insecure=true)
- "8080:8080"
networks:
- web
volumes:
- "./letsencrypt:/letsencrypt"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
networks:
web:
external: true
That middleware label needs to be defined in a dynamic provider, easiest would be docker label or in a file provider. You could add this as a label to the traefik container.
The middleware then has to be attached to a router or you can add middlewares to an entryPoint and the will apply to all routers.