2

HTTP (web) servers have the possibility to handle two different host names (site1.example.com and site2.example.com) which both point to the same IP and port. This is because the protocol embarks the name of the target server (as part of the URI) which in turns makes it possible for the server to know which name was queried. It is then possible to reverse-proxy these calls to other servers, which are unknown to the original caller.

This is very practical when one has one IP and wants to use several server names.

Is such a setup possible for Minecraft servers? By "setup" I mean a server that understands which server was queried and is able to redirect such call to another server. I could then have, with one IP, the traffic for the names 1.9.example.com and 1.10.example.com redirected to internal servers.

The alternate solution is of course to use different ports, but I would like to keep the default ones.

  • Note that this only works for HTTP because every HTTP request includes a mandatory Host field in the header which states the domain name the request is intended for. I doubt that Minecraft has anything like that. – Philipp Apr 16 '17 at 14:46
  • I have created a program for that. npmjs.com/package/mcrevproxy. – janispritzkau Feb 26 at 9:13
3

It is possible, but I don't believe the tools you need to do it exist. You would have to develop your own custom software.

The minecraft client actually sends the server IP used to connect in one of the first packets it sends, so if you intercept that packet and put the IP into some sort of table, you can then route traffic based on that. But as far as I know, nothing like this currently exists, so it'd really only be feasible if you could write it yourself.

The other option would be to use SpigotMC's BungeeCord, which doesn't do exactly what you're asking, but something similar. You connect to one ip and then the BungeeCord server routes you between several other minecraft servers depending on how it's configured. This sounds like it might work for you, although you would have to sacrifice using different IPs.

  • Thank you. It looks like BungeeCord is a good compromise. – WoJ Apr 19 '17 at 20:32
1

Yes it is possible.

You can use sslh

sslh acts as a port protocol-demultiplexer, or reverse proxy in a way. It sniffs the first packet, determines the protocol and routes the traffic to the desired ip on the appropriate port as defined by your configuration file.

In my case I'm not able to open any other port than 80 and 443 (a common problem) so I already had sslh installed and demultiplexing ssh and https through port 443 and I wanted to add minecraft to that process. So I just edited the config file located for me (ubuntu 14.04/16.04) etc/default/sslh to read as follows:

DAEMON_OPTS="--user sslh --listen 192.168.0.100:443 --ssh 127.0.0.1:22 --ssl 127.0.0.1:443 --anyprot 127.0.0.1:25565 --pidfile /var/run/sslh/sslh.pid"

The line is read sequentially, First it listens on the servers local ip on port 443 as passed to the server from my router, then it first looks for ssh traffic which is redirected to the loopback ip on port 22, then it looks for ssl/https traffic which is redirected to the loopback ip at port 443, then anything left over is sent to the minecraft port on the loopback ip.

In your case,with just one minecraft server you could just set the appropriate ip for the destination rather than the loopback ip (127.0.0.1) that I used.

If however you have multiple minecraft server subdomains you could, because the minecraft protocol includes the destination address in the first packet which includes the subdomain, write an appropriate regex sniff line for that packet explicitly, as described in the documentation, and subsequently send the individual traffic off to each ip as desired rather than just a different port on the loopback address as I did.

I didn't need to though since I only had one minecraft server and the "any other protocol" --anyprot flag and loopback address was sufficient for me.

Finally when I tested my_minecraft_server.mywebsite.tld:443 on this neat online minecraft status tester It worked. Yay.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.