Enable HSTS with docker

Hello,

I’m pretty new to traefik (and reverse proxies in general).

I’m using version 3.6 and I’m trying to enable HSTS on my website (self hosted on docker). From what I see traefik configuration is good.

Got the right labels in my docker compose file

labels:

  • traefik.enable=true
  • traefik.docker.network=traefik_proxy
  • traefik.http.routers.mysite-https.rule=Host(mysite.domain.com)
  • traefik.http.routers.mysite-https.entrypoints=websecure
  • traefik.http.routers.mysite-https.tls=true
  • traefik.http.routers.mysite-https.tls.certresolver=ovhcloud
  • traefik.http.middlewares.mysiteHeader.headers.stsSeconds=15552000
  • traefik.http.middlewares.mysiteHeader.headers.stsIncludeSubdomains=true
  • traefik.http.middlewares.mysiteHeader.headers.stsPreload=true
  • traefik.http.middlewares.mysiteHeader.headers.forceSTSHeader=true

I can see in the dashboard that configuration is applied:

But when I go to ssllabs to test my url, it tells me HSTS is not enabled:

Capture d'écran 2025-12-17 101450

Can you help me to find what I’m missing here ?

Thanks

You declared the middlewares (doc), but you also need to assign it to the router:

- traefik.http.routers.mysite-https.middlewares=mysiteHeader

1 Like

Thank you for your answer. HSTS is working now

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