timvisee / lazymc

💤 Put your Minecraft server to rest when idle.
GNU General Public License v3.0
579 stars 16 forks source link

Reverse proxy to multiple minecraft servers based on domain #40

Open timvisee opened 1 year ago

timvisee commented 1 year ago

Discussed in https://github.com/timvisee/lazymc/discussions/35

Originally posted by **tW4r** December 21, 2022 This project already does proxying `internet:25565 -> lazymc:25565 -> minecraft server:25566` It is possible to determine the domain the user is connecting to from the login packet Based on this fact it is possible to direct them to different minecraft servers as such ``` server-a.example.com:25565 \ / minecraft server-a:25566 +-> lazymc:25565 ->+ server-b.example.com:25565 / \ minecraft server-b:25567 ``` An example of this is infrared (https://github.com/haveachin/infrared) I would imagine it could work by splitting `lazymc.toml` to multiple files in a config directory: ``` # file 1 [public] address="server-a.example.com" [server] address="127.0.0.1:22566" ``` ``` # file 2 [public] address="server-b.example.com" [server] address="127.0.0.1:22567" ```
tW4r commented 1 year ago

I've added a draft PR #42 for this, if you have some time it'd be great if you could tell me if I'm going the right direction

joesturge commented 2 months ago

If you use docker, I have created a solution to this problem: https://github.com/joesturge/lazymc-docker-proxy?tab=readme-ov-file#multiple-server-support