# Connecting to Minecraft server via TCP trhough Traefik

**URL:** <https://community.traefik.io/t/connecting-to-minecraft-server-via-tcp-trhough-traefik/14146>\
**Category:** Traefik v2\
**Tags:** tcp, docker\
**Created:** [April 14, 2022, 6:43pm UTC](https://community.traefik.io/t/connecting-to-minecraft-server-via-tcp-trhough-traefik/14146 "2022-04-14T18:43:13Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![louisonsarlinmagnus](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/louisonsarlinmagnus/32/5220_2.png) [@louisonsarlinmagnus](https://community.traefik.io/u/louisonsarlinmagnus)\
**Post date:** [April 14, 2022, 6:43pm UTC](https://community.traefik.io/t/connecting-to-minecraft-server-via-tcp-trhough-traefik/14146/1 "2022-04-14T18:43:13Z")

</div>

Hi all,

I'm trying to connect to my minecraft-server container via TCP as shown bellow:

 ![mc_bug_reseau](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/9/9d47ae12f68862a6b3137651803896e880fcb7c2.png)

Here is my traefik docker-compose

```auto
traefik:
  container_name: traefik
  restart: unless-stopped
  image: traefik:rocamadour
  command:
    - --log.level=INFO
  ports: #Liste les ports a exposer
    - 80:80
    - 443:443
    - 2565:25565/tcp

  volumes: #On décrit les volumes a monter dans le container
    - /var/run/docker.sock:/var/run/docker.sock
    - /home/louison/turbonas/traefik/acme.json:/acme.json
    - /home/louison/turbonas/traefik/.htpasswd:/.htpasswd
    - /home/louison/turbonas/traefik/traefik.yaml:/traefik.yaml
    - /home/louison/turbonas/traefik/traefik_dynamic.yaml:/traefik_dynamic.yaml

  environment:
    - TZ=Europe/Paris

```

And here is entryPoint configured:

```auto
entryPoints:
  minecraft:
    address: ':25565/tcp'

```

And finally here is my container:

```auto
vanilla:
  container_name: vanilla
  restart: unless-stopped
  image: itzg/minecraft-server
  volumes:
  - /home/louison/turbonas/minecraft/vanilla/data:/data
  environment:
    EULA: "true"
    DEBUG: "true"
  labels:
  - traefik.tcp.routers.vanilla.rule=HostSNI(`my.domain.fr`)
  - traefik.tcp.routers.vanilla.entrypoints=minecraft

```

When I try to access my container I can see using `sudo tcpdump -i any -vv tcp port 25565` that some packets are incorrects:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/4/4defae4754dbb7c979050300b0735e2aafb44f4a.png)

I think that Traefik is reading or alter packets while sending them to my container.

Is there a way to configure Traefik not to read or not to alter packets?

**Thanks all**

_P.S.: Sorry if it's not really clear, I'm a French network newbie._

---

<div class="post-metadata">

**Author:** ![benvanstaveren](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/benvanstaveren/32/4530_2.png) [@benvanstaveren](https://community.traefik.io/u/benvanstaveren)\
**Post date:** [April 15, 2022, 7:07am UTC](https://community.traefik.io/t/connecting-to-minecraft-server-via-tcp-trhough-traefik/14146/2 "2022-04-15T07:07:48Z")

</div>

As far as I know, Minecraft doesn't use TLS, so you can't use HostSNI as a rule since there is no SNI header.

---

<div class="post-metadata">

**Author:** ![louisonsarlinmagnus](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/louisonsarlinmagnus/32/5220_2.png) [@louisonsarlinmagnus](https://community.traefik.io/u/louisonsarlinmagnus)\
**Post date:** [April 15, 2022, 8:06am UTC](https://community.traefik.io/t/connecting-to-minecraft-server-via-tcp-trhough-traefik/14146/3 "2022-04-15T08:06:21Z")

</div>

Oh thanks, ok I can see my mistake now!  
So since Minecraft doesn't need TLS I cannot use any rule like `my.domain.fr` or is it possible to configure a specific rule?

Thank you

---

<div class="post-metadata">

**Author:** ![benvanstaveren](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/benvanstaveren/32/4530_2.png) [@benvanstaveren](https://community.traefik.io/u/benvanstaveren)\
**Post date:** [April 15, 2022, 8:23am UTC](https://community.traefik.io/t/connecting-to-minecraft-server-via-tcp-trhough-traefik/14146/4 "2022-04-15T08:23:09Z")

</div>

No, you'll have to go port based. Each entrypoint = 1 route to a minecraft server. To attach a hostname to it, you want to look into SRV records (DNS); SRV records can have pointers that if you visit [my.domain.fr](http://my.domain.fr) it will look up not just the IP, but also the port for Minecraft.

That's why if you want to host multiple minecraft servers you don't really need Traefik at all, just need SRV records in DNS and that'll do the trick.

---

<div class="post-metadata">

**Author:** ![louisonsarlinmagnus](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/louisonsarlinmagnus/32/5220_2.png) [@louisonsarlinmagnus](https://community.traefik.io/u/louisonsarlinmagnus)\
**Post date:** [April 15, 2022, 8:33am UTC](https://community.traefik.io/t/connecting-to-minecraft-server-via-tcp-trhough-traefik/14146/5 "2022-04-15T08:33:46Z")

</div>

Thanks, it's much more clear.  
I think I will go without Traefik for Minecraft for now.

Have a nice day !

---

<div class="post-metadata">

**Author:** ![tommoulard](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/tommoulard/32/2997_2.png) [@tommoulard](https://community.traefik.io/u/tommoulard)\
**Post date:** [April 15, 2022, 10:00am UTC](https://community.traefik.io/t/connecting-to-minecraft-server-via-tcp-trhough-traefik/14146/6 "2022-04-15T10:00:58Z")

</div>

> [@louisonsarlinmagnus](#):
>
> ```auto
> - 2565:25565/tcp
> 
> ```

You seem to have a typo on the docker-compose file

And you don't have to use TLS for TCP routing with Traefik.  
You can use the `HostSNI(`*`)` matcher special case for this.

> **Here's how I would do it**
>
> ```yaml
> version: '3.9'
> 
> services:
> traefik:
> image: traefik:v2.7
> command:
> - --providers.docker
> - --entrypoints.minecraft.address=:25565
> ports:
> - 25565:25565/tcp
> volumes:
> - /var/run/docker.sock:/var/run/docker.sock
> 
> vanilla:
> container_name: vanilla
> restart: unless-stopped
> image: itzg/minecraft-server
> volumes:
> - ./data:/data
> environment:
> EULA: "true"
> DEBUG: "true"
> labels:
> - traefik.tcp.routers.vanilla.rule=HostSNI(`*`)
> - traefik.tcp.routers.vanilla.entrypoints=minecraft
> 
> ```

---

<div class="post-metadata">

**Author:** ![Kraoc](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/kraoc/32/8210_2.png) [@Kraoc](https://community.traefik.io/u/Kraoc)\
**Post date:** [November 2, 2022, 6:25pm UTC](https://community.traefik.io/t/connecting-to-minecraft-server-via-tcp-trhough-traefik/14146/7 "2022-11-02T18:25:51Z")

</div>

I'm a french guy too...

Here is how I setup Docker/Pterodactyl/Minecraft behind Cloudflare/Traefik:

> **[Pterodactyl](https://blog.zogg.fr/fr/blog/docker/stacks/pterodactyl)**
>
> Mise en place d’une stack Docker pour faire tourner Pterodactyl sous une machine ARM64.Connaissances requises pour ce tuto :..Linux (shell, script, Bash, pig, gid, uid, systemd, ip, port).Docker

With this you'll need to have setup before:

- Docker
- Portainer
- Traefik

And you'll get:

- Pterodactyl
- A subdomain for the panel and another for a node
- SSL
- Cloudflare protection & caching

I realized that I need to update my tuto as I also works on amd64 😛

---

<div class="post-metadata">

**Author:** ![Kraoc](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/kraoc/32/8210_2.png) [@Kraoc](https://community.traefik.io/u/Kraoc)\
**Post date:** [November 12, 2022, 7:13am UTC](https://community.traefik.io/t/connecting-to-minecraft-server-via-tcp-trhough-traefik/14146/8 "2022-11-12T07:13:49Z")

</div>

Can't update my previous post.  
I switch from Grav to Ghost and changed my subdomain...  
So, article is now here: [Pterodactyl](https://infos.zogg.fr/pterodactyl/)  
My apologizes.

---

<div class="post-metadata">

**Author:** ![tsla](https://avatars.discourse-cdn.com/v4/letter/t/34f0e0/32.png) [@tsla](https://community.traefik.io/u/tsla)\
**Post date:** [February 3, 2024, 1:40pm UTC](https://community.traefik.io/t/connecting-to-minecraft-server-via-tcp-trhough-traefik/14146/9 "2024-02-03T13:40:55Z")

</div>

English version anytime soon? I think it would help others a lot

---

<div class="post-metadata">

**Author:** ![Kraoc](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/kraoc/32/8210_2.png) [@Kraoc](https://community.traefik.io/u/Kraoc)\
**Post date:** [February 3, 2024, 5:48pm UTC](https://community.traefik.io/t/connecting-to-minecraft-server-via-tcp-trhough-traefik/14146/10 "2024-02-03T17:48:54Z")

</div>

> **[Pterodactyl](https://infos-zogg-fr.translate.goog/pterodactyl/?_x_tr_sl=auto&_x_tr_tl=us&_x_tr_hl=us&_x_tr_pto=wapp)**
>
> Connaissances requises pour ce tuto : Linux (shell, script, Bash, pid, gid, uid, systemd, ip, port) Docker Docker Compose Portainer Cloudflare (domaine et DNS) Caddy Api (le principe) CORS (pour que ça fonctionne)

😇

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [February 3, 2024, 6:20pm UTC](https://community.traefik.io/t/connecting-to-minecraft-server-via-tcp-trhough-traefik/14146/11 "2024-02-03T18:20:53Z")

</div>

![Google-translate-dog](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/f/f160694cbf4e5038a7106a0aa7c165ae6ab3c5e9.png)

🤣

The link seems broken, but [Google translate](https://translate.google.com/?sl=auto&tl=en&op=websites) is a good answer to be used with `https://infos.zogg.fr/pterodactyl/`.

---

<div class="post-metadata">

**Author:** ![Kraoc](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/kraoc/32/8210_2.png) [@Kraoc](https://community.traefik.io/u/Kraoc)\
**Post date:** [February 4, 2024, 10:06am UTC](https://community.traefik.io/t/connecting-to-minecraft-server-via-tcp-trhough-traefik/14146/12 "2024-02-04T10:06:17Z")

</div>

I tried it in private browsing mode to make sure it worked... no luck :frowning :

I'm writing in French because there are few detailed articles in French compared to all those written in English. It's a conscious choice of popularization 🙂
