Hello @Dreimus ,
I ran into a similar issue, but in my case with Postgres. I was able to get it to work, but with those things in place:
-
I am using Traefik v3 (in my case v3.0.0-beta3); The STARTTLS feature for Postgres is only in that version onward (I know you are using MariaDB, but just FYI);
-
I had to set the database port in my container to be the same as exposed on the host (i.e. 5432 on host and 5432 in container); This was the cause of my connection timeout;
-
I don't use TLS for the database in the container, only at the Traefik entrypoint with the labels;
-
I need to set at least one TCP entrypoint port for all the DB connections on Traefik (i.e. 5432). If your Traefik runs on the same host as your DB, you will need to change this so you don't have a port conflict.
-
I set the following Traefik labels:
"traefik.enable=true", "traefik.tcp.routers.postgres-db.rule=HostSNI(`postgres-db.${domain}`)", "traefik.tcp.routers.postgres-db.tls=true" "traefik.tcp.routers.postgres-db.entrypoints=postgres" -
Make sure your have a default cert on Traefik for ${domain} or you will have to specify it. I don't use passthrough as I don't have TLS enabled on the DB.
-
I think in your case you will have to specify a service backend port and address (in the Traefik labels) if you don't have service discovery capabilities in your system.
With all of that in place, I am able to have one port and use HostSNI to send the traffic to my different databases. i.e.:
my-db-1.example.com:5432 (goes to db1 backend container)
my-db-2.example.com:5432 (goes to db2 backend container)
my-db-3.example.com:5432 (goes to db3 backend container)
Hope this was useful to you.
Joey