Configure TCP whoamitcp

Hi !
I'm trying to get up my first traefik server.
Https works and the basic configuration works.

Now, I want a tcp redirect but i'm not able to understand how it works.
I'm a little newbie in the network world.
I've tried this :

version: "3.3"

services:
  traefik:
    image: "traefik"
    command:
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      - --entrypoints.autre.address=:8080

      - --providers.docker
      - --api
      - --certificatesresolvers.leresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
      - --certificatesresolvers.leresolver.acme.email=re@re.com
      - --certificatesresolvers.leresolver.acme.storage=/acme.json
      - --certificatesresolvers.leresolver.acme.httpChallenge.entryPoint=web
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - "./acme.json:/acme.json"
    labels:
      # Dashboard
      - "traefik.http.routers.traefik.rule=Host(`traefik.fr`)"
      - "traefik.http.routers.traefik.service=api@internal"
      - "traefik.http.routers.traefik.tls.certresolver=leresolver"
      - "traefik.http.routers.traefik.entrypoints=websecure"
      - "traefik.http.routers.traefik.middlewares=authtraefik"
      - "traefik.http.middlewares.authtraefik.basicauth.users=user:$$apr1$$q8eZFHjF$$Fvmkk//V6Btlaf2i/ju5n/" # user/password
      
      # global redirect to https
      - "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
      - "traefik.http.routers.http-catchall.entrypoints=web"
      - "traefik.http.routers.http-catchall.middlewares=redirect-to-https"

      # middleware redirect
      - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"

  my-app:
    image: containous/whoami
    labels:
      - "traefik.http.routers.my-app.rule=Host(`whoami.fr`)"
      - "traefik.http.routers.my-app.middlewares=auth"
      - "traefik.http.routers.my-app.entrypoints=websecure"
      - "traefik.http.routers.my-app.tls=true"
      - "traefik.http.routers.my-app.tls.certresolver=leresolver"
      - "traefik.http.middlewares.auth.basicauth.users=user:$$apr1$$q8eZFHjF$$Fvmkk//V6Btlaf2i/ju5n/" # user/password

  my-tcp-app:
    image: containous/whoamitcp
    labels:
      - "traefik.tcp.routers.my-tcp-app.rule=HostSNI(`whoamitcp.fr`)"
      - "traefik.tcp.routers.my-tcp-app.tls.passthrough=true"
      - "traefik.tcp.routers.my-tcp-app.tls=true"
      - "traefik.tcp.routers.my-tcp-app.tls.certresolver=leresolver"

      - "traefik.tcp.routers.my-tcp-app.entrypoints=autre"
      - "traefik.tcp.services.my-tcp-app.loadbalancer.server.port=8080"

I've downloaded packet sender to send tcp paquets to my server. And I receive "unable to connect".
In my dashboard, everything is ok.

What I suppose to get back on my screen if TCP paquet success ?
My config is ok ?

Thanks for your help !

UP !

Do you have any ideas how to test TCP connection and any basic configuration to create my first TCP container ?

Thanks :slight_smile:

tcp connections are typically used by software, and said software ususally have client and server components, which allows the client to connect to server that listens to incoming tcp connection. To test the connection you should be using the client corresponding to your server.

For example for a web server, you will use a web browser, for Microsoft Sql Server you will use Microsoft Sql Server Management Studio, or sqlcmd, For sshd you will use ssh, etc.

A generic way to see if server accepts tcp connections is to use telnet or netcat (nc).

Thanks you for your reply !

But I don't really success.
I'm triing tcp connexion with whoamitcp : https://github.com/containous/whoamitcp
And I have nothing to output...

netcat whoamitcp.????.rwanito.fr 25565 
HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8  
Connection: close                                                                                                                                                                                                                               400 Bad Request

Why http ?

I'm a little lost :smiley:

It's hard to tell, because it seems you obfuscated the domains in one way in your config and in a different way in this examlpe above.

What it amounts to that your url seems to be matched by http(s) router and not by the tcp one, you will need to double check the matching rules.

Same issue here - how to debug route matching in Traefik 2.2?

Steve

Dashboard and debug log. If you have problems post your configs and logs and describe what's not working.