# Trying to route two Terraria servers based on domain name using same port

**URL:** <https://community.traefik.io/t/trying-to-route-two-terraria-servers-based-on-domain-name-using-same-port/8221>\
**Category:** Traefik v2\
**Tags:** tcp\
**Created:** [October 18, 2020, 3:43am UTC](https://community.traefik.io/t/trying-to-route-two-terraria-servers-based-on-domain-name-using-same-port/8221 "2020-10-18T03:43:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![atg22896](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/atg22896/32/5484_2.png) [@atg22896](https://community.traefik.io/u/atg22896)\
**Post date:** [October 18, 2020, 3:43am UTC](https://community.traefik.io/t/trying-to-route-two-terraria-servers-based-on-domain-name-using-same-port/8221/1 "2020-10-18T03:43:37Z")

</div>

My goal is to be able to use [terraria.domain.com:7777](http://terraria.domain.com:7777) to get in first server, and [terraria2.domain.com:7777](http://terraria2.domain.com:7777) in order to get into second. But using the :7777 port is always getting routed to the first image. It appears that the HostSNI is behaving like a wildcard.

```auto
    terraria:
        image: atgomez6555/terraria:tshock-latest
        container_name: terraria
        ports:
            - 7777:7777
        environment:
            - world=Avernus.wld
        volumes:
            - /home/alex/docker/terraria/config:/config
        tty: true
        stdin_open: true
        restart: unless-stopped
        labels:
            traefik.enable: "true"
            traefik.tcp.routers.terraria.entrypoints: "terraria"
            traefik.tcp.routers.terraria.rule: "HostSNI(`terraria.domain.com`)"
            traefik.tcp.routers.terraria.tls: "true"
        depends_on:
            - traefik

    terraria2:
        image: atgomez6555/terraria:tshock-latest
        container_name: terraria2
        ports:
            - 7778:7778
        environment:
            - world=The_Island_of_Silver.wld
        volumes:
            - /home/alex/docker/terraria/config2:/config
        tty: true
        stdin_open: true
        restart: unless-stopped
        labels:
            traefik.enable: "true"
            traefik.tcp.routers.terraria2.entrypoints: "terraria"
            traefik.tcp.routers.terraria2.rule: "HostSNI(`terraria2.domain.com`)"
            traefik.tcp.routers.terraria2.tls: "true"
        depends_on:
            - traefik

```

And this is my toml config file:

```auto
# [global]
[log]
  level = "INFO"

[entryPoints]
  [entryPoints.web]
    address = ":80"
    [entryPoints.web.http.redirections.entryPoint]
      to = "websecure"
      scheme = "https"

  [entryPoints.websecure]
    address = ":443"

  [entryPoints.traefik]
    address = ":8083"

  [entryPoints.terraria]
    address = ":7777"
  

[providers]
  providersThrottleDuration = "2s"
  [providers.docker]
    swarmModeRefreshSeconds = "15s"
    exposedByDefault = false
    endpoint = "unix:///var/run/docker.sock"

[api]
  insecure = true
  dashboard = true

[ping]
  # terminatingStatusCode = 0

[certificatesResolvers]
  [certificatesResolvers.default]
    [certificatesResolvers.default.acme]
      email = "xxxx"
      storage = "acme.json"
      [certificatesResolvers.default.acme.dnsChallenge]
        provider = "cloudflare"
        delayBeforeCheck = "0s"
        resolvers = ["dara.ns.cloudflare.com", "elliot.ns.cloudflare.com"]

```

Ideally I do not want to have to port forward a separate port for every server I run.

---

<div class="post-metadata">

**Author:** ![zespri](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/zespri/32/310_2.png) [@zespri](https://community.traefik.io/u/zespri)\
**Post date:** [October 18, 2020, 7:24am UTC](https://community.traefik.io/t/trying-to-route-two-terraria-servers-based-on-domain-name-using-same-port/8221/2 "2020-10-18T07:24:01Z")

</div>

Well, `SNI` is a TLS concept, and games rarely use TLS for their connection (unless they use HTTP(S) as the protocol).

In short, what you are trying to achieve is impossible in principle.

---

<div class="post-metadata">

**Author:** ![atg22896](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/atg22896/32/5484_2.png) [@atg22896](https://community.traefik.io/u/atg22896)\
**Post date:** [October 18, 2020, 8:40am UTC](https://community.traefik.io/t/trying-to-route-two-terraria-servers-based-on-domain-name-using-same-port/8221/3 "2020-10-18T08:40:56Z")

</div>

Ok, I'm still trying to learn this. So 1 port per server running is pretty much a technical requirement? Thanks for the insight. At least I'm still able to give a name via proxy vs. having to use IP.

---

<div class="post-metadata">

**Author:** ![zespri](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/zespri/32/310_2.png) [@zespri](https://community.traefik.io/u/zespri)\
**Post date:** [October 18, 2020, 8:43am UTC](https://community.traefik.io/t/trying-to-route-two-terraria-servers-based-on-domain-name-using-same-port/8221/4 "2020-10-18T08:43:01Z")

</div>

Yeah, there is no public information in the incoming connection that could help deduce which server it's intended for.

---

<div class="post-metadata">

**Author:** ![badangrycloud](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/badangrycloud/32/3406_2.png) [@badangrycloud](https://community.traefik.io/u/badangrycloud)\
**Post date:** [February 17, 2021, 3:24pm UTC](https://community.traefik.io/t/trying-to-route-two-terraria-servers-based-on-domain-name-using-same-port/8221/5 "2021-02-17T15:24:09Z")

</div>

@atg22896 How do you do to connect the client of terraria through traefik?
