Traffic routing to wrong service with https passthrough and https

Hi, I have a very strange behaviour :
I have to docker-compose.yml files wich exposes services through labels. One has an https passthrough, the other has an SSL cert configured with the dynconf file provider in a watched directory.

Here the confs:

  • Mailu config
      - "traefik.enable=true"                                                                                                                                                                                                                                                                                              
      - ""                                                                                                                                                                                                                                                                                 
      - "traefik.http.routers.mailuhttp.rule=Host(``) || Host(``) || Host(``) || Host(``) || Host(``) || Host(``) || Host(`
`) || Host(``) || Path(`/.well-known/acme-challenge/`)"                                                                                                                                                                                                                                        
      - "traefik.http.routers.mailuhttp.entrypoints=web"                                                                                                                                                                                                                                                                   
      - ""                                                                                                                                                                                                                                                      
      - "traefik.tcp.routers.mailuhttps.rule=HostSNI(``) || HostSNI(``) || HostSNI(``) || HostSNI(``) || HostSNI(``) || HostSNI(``) || HostSNI(`mta-sts.`) || HostSNI(``) || HostSNI(``) || HostSNI(``) || HostSNI(``)"                                                                                                                      
      - "traefik.tcp.routers.mailuhttps.entrypoints=websecure"                                                                                                                                                                                                                                                             
      - "traefik.tcp.routers.mailuhttps.tls.passthrough=true"                                                                                                                                                                                                                                                              
      - "traefik.tcp.routers.mailuhttps.service=mailuhttps"                                                                                                                                                                                                                                                                
      - ""                                                                                                                                                                                                                                                     
      - ""
  • Mattermost config:
      - "traefik.enable=true"
      - ""
      - "traefik.http.routers.mattermost-http.entrypoints=web"
      - "traefik.http.routers.mattermost-http.rule=Host(``) || Host(``)"
      - "traefik.http.routers.mattermost-http.middlewares=mattermost-https"
      - "traefik.http.middlewares.mattermost-https.redirectscheme.scheme=https"
      - "traefik.http.routers.mattermost.entrypoints=websecure"
      - "traefik.http.routers.mattermost.rule=Host(``) || Host(``)"
      - "traefik.http.routers.mattermost.tls=true"
      - ""

Here are some reproductible (at least on my host...) scenarios and how it behave depending on the order container are started:

  • traefik > mailu > mattermost:
  • traefik routes to mailu (instead of mattermost). is correctly routed.
  • traefik > mattermost
    • traefik routes correctly to mattermost
  • traefik > mattermost > mailu
    • mattermsot is correctly routed, but mailu returns a 404

What is even weirder, is that in the dashboard, everything reported is as expected...

These behaviours seems strange enough to be a feature, should I file a bug or is it something wrong with my config ?

Share your full Traefik static and dynamic config, and docker-compose.yml if used.

What does Traefik debug log and dashboard tell you?

Are you sure || Path(`/.well-known/acme-challenge/`) works? Usually it’s best to use PathPrefix().

In general I would place a http->https redirect globally on the entrypoint, to not have it in labels on every service, see simple Traefik example.

We use mailu, too, but because of all the special ports required, mostly not using http, we have it on its own VPS with own IP.

|| Path(/.well-known/acme-challenge/) I kept the rule if someday I use let's encrypt, but I have my own certs.

Anyway, I used direct https request without going throug the redirects in my tests.

My best guess so far is that (I don't know why) mailuhttps matches all request !

I know tcp routers have precedence to http ones, but HostSNI should not match :confused:

I tried with only


to ruleout a typo, and it keeps redirecting * to mailu...

Share your full Traefik static and dynamic config, and docker-compose.yml if used.

How do you test the requests? With curl?

even weired : it works now while I don't recall having touched anything...

Your last reply recall me I used my web browser, and maybe some redirection cache.

So an hypothesis is that at some time, I may have had a typo in the rule, which made invalid and match everything... And since tcp has precedence, it stopped evaluation of other rules.

I retested with command like

wget --bind-address=

and everything was fine...

I have the problem only on web browser so here what I think :

At each new connection, the routing is done well, but if the same tcp connection is reused, then it tries to issue the request to the initial service !