Hi, I'm struggling with an issue related to middlewares.
I have created a middleware named secure-headers
in my traefik.yml
file, and I'm trying to reference it my docker-compose.yml
file, but it keeps telling me the middleware does not exist.
I've defined the following in my traefik.yml
file:
# ... other configuration here (let me know if you need to see it)
middlewares:
secure-headers:
headers:
stsSeconds: 31536000 # Strict-Transport-Security
stsIncludeSubdomains: true
stsPreload: true
browserXssFilter: true # X-XSS-Protection
frameDeny: true # X-Frame-Options
featurePolicy: "vibrate 'none';" # Feature-Policy header
contentTypeNosniff: true # X-Content-Type-Options
referrerPolicy: "strict-origin-when-cross-origin"
and in my docker-compose.yml
:
# ...other configuration here (let me know if you need to see it)
traefik:
image: "traefik:v2.1"
ports:
- "80:80"
- "443:443"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./traefik.yml:/traefik.yml:ro"
- "./certs:/certs:ro"
labels:
- "traefik.enable=true"
- "traefik.http.routers.http-catchall.rule=hostregexp(`{host:[a-z-.]+}`)"
- "traefik.http.routers.http-catchall.entrypoints=web"
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
- "traefik.http.routers.http-catchall.middlewares=secure-headers@file"
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
and finally, in my logs:
traefik_1 | time="2020-03-11T16:31:45Z" level=error msg="middleware \"secure-headers@file\" does not exist" entryPointName=web routerName=http-catchall@docker