itzg / mc-router

Routes Minecraft client connections to backend servers based upon the requested server address

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot find the server on client servers list

Pandaw15 opened this issue · comments

Using Docker 20.10.21
and Docker Compose v2.18.1

Hi ! I already had a server on another machine via LAN, and wanted to play another modpack; and found the mc router image to have both on the same machine.
I changed my docker compose file (https://pastebin.com/bQSW4UVS) to account for that, and moved it to home/mable/ instead of home/mable/mc-docker, where he was initially when there was only one server. I don't know if I should have moved it, but since the directory he was in before became the sole volume of the first server (I made "colony-docker" for the other one) I thought maybe it wouldn't be read correctly since I plan on not starting this container.

When I put "minecolonies.bubble.com" into the server address, I don't get a ping response.

I can see both servers loading via the logs, so I don't think it's that.
I think I messed up with the hosts part. Maybe it's because of the yml version (I changed the version from 3 to 3.8 without updating Docker/Docker Compose; I think it's just formatting ?), or that I wanna connect via LAN, and the hosts should have other ports or something.

Any idea on what I've done wrong ?

The use of extra_hosts seems wrong especially pointing those at the loopback IP address. (The loopback device is going to be distinct for each container by default.) Was there a reason to add those?

I wanted to add them to the hosts file so that I can have the user (me) type a server adress in their client, the router reads it, links it to the correct service, and connects the user to this service (https://dev.to/jam3sn/routing-to-multiple-minecraft-servers-on-a-host-307h).

I believe we can only update the hosts file on runtime, and I read of this implementation while searching how to change the file (https://stackoverflow.com/questions/38302867/how-to-update-etc-hosts-file-in-docker-image-during-docker-build).

Maybe the issue here is that I'm redirecting to the localhost (127.0.0.1), but the server and client aren't on the same machine; so I'd need something else ?
I don't really know the interactions well; like if the server tells the client to look at its own localhost and 25565 port, or if it just can't send it to the client since packets from local host can't travel outside the machine, or if it doesn't matter and all that is operating inside the server correctly, and the router sends another host:ip combination I don't see.

You're mixing and matching too many concepts there. That mc-router article is good; however, I think they shouldn't have mentioned the /etc/hosts part especially with saying you can put "localhost" there. The intention is that

  1. You have a public IP address that can be accessed by all the clients/users
  2. You own a domain. Your compose file lists bubble.com -- do you own and manage that domain? I'm venturing a guess you don't. You can buy one at a provider like https://www.namecheap.com/
  3. You have pre-created A records in that domain that all point to your public IP address. Those fully qualified domain names will be referenced by the mc-router routes

For your second point, I thought that was why we wanted to add them to the hosts file, so that I can have the hostname locally instead of having a public domaine name (since I'm only using LAN).

At https://github.com/itzg/mc-router, it talks about Kubernetes and how we can register something as the external hostname. Would this need to own a public domain as well ? I only want to access this in LAN.

When running on a LAN, I wouldn't even recommend using mc-router. Just point to the host and port of the LAN machine.

If you do still want to use on a LAN, then each client's machine will need the hosts file setup correctly with the LAN IP address and the fake hostnames. The extra_hosts item is for managing the container hosts file, but that's not relevant for your scenario.

Alright, thanks for the explanations! I'll try and use the basic different ports method; I'll close this issue if/when I get it to work.