Redirect non-HTTP traffic to a subdomain-based port

I am working on making my two Minecraft servers available. I tried to make some decisions, but so far no one has worked effectively.

I have a regular Minecraft vanilla server listening on mysite.com:25560 and a Tekkit Minecraft server listening on mysite.com:25570. That is, both Minecraft servers are running on the same machine. They work correctly when users connect directly to the server with the specified port.

Initially, the vanilla server listened for mysite.com:25565, the standard Minecraft port. I modified it so that I can let Apache listen on mysite.com:25565 and redirect the traffic accordingly, but this does not work yet.

What I would like to do is all requests sent to my.mysite.com will be redirected to mysite.com:25560, and all requests sent to tekkit.mysite.com will be redirected to mysite.com: 25570. I understand that DNS itself is not able to handle this redirection, since DNS only processes domain names and IP addresses.

Following a friend’s suggestion, my last attempt reconfigured Apache, as I said, to listen on port 25565 and proxy traffic to the correct port. This is the section of my apache2.conf:

Listen 25565 NameVirtualHost *:25565 <VirtualHost *:25565> ServerName tekkit.mysite.com ServerAlias www.mysite.com <Proxy *> Order allow,deny Allow from all </Proxy> ProxyPreservehost On # ProxyPass / www.mysite.com:25570/ ProxyPassReverse / mysite.com:25570/ </VirtualHost> <VirtualHost *:25565> ServerName mine.mysite.com ServerAlias www.mysite.com ProxyPreserveHost On <Proxy *> Order allow,deny Allow from all </Proxy> # ProxyPass / mysite.com:25560/ ProxyPassReverse / mysite.com:25560/ </VirtualHost> 

The recorded lines with ProxyPass cause Apache to start with an error. The URL of the ProxyPass must be absolute!

To find out if I can make it work correctly, I then tried to replace http://www.mysite.com:25560/60 in the appropriate places, and when Apache starts without any errors, users cannot connect to the server. I believe that this is due to the fact that the Minecraft server does not redirect an HTTP request to connect to the server, whatever the protocol.

This led me to think that Apache would not be useful in processing requests other than HTTP. If I am mistaken, how can I get Apache to properly redirect subdomain traffic to a port? Otherwise, can anyone suggest a way to do this without Apache? I have access to all the standard Linux / Ubuntu utilities. I searched quite a lot of time without progress.

Thanks!

+4
source share
2 answers

Solution 1:

I do not think this will work with Apache since you can only get errors. After doing some searching on the Internet, I found the following: https://github.com/SirCmpwn/MCVHost . I'm not sure if it works, but if it does it is perfect for your needs, I think.

If you are running Linux, you can run it using Mono since I have not found the equivalent of Java or Python.

Edit: I just tested it and it does not work with 1.4.6 because the protocol has changed

Solution 2 (and probably the best):

Use SRV records that Minecraft has recognized since version 1.3. The guide was published by Multiplay at http://wiki.multiplay.co.uk/Minecraft/Hostnames .

+2
source

I believe iptables will do this for you if you are on Linux:

 iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 25565 -j REDIRECT --to-port 25560 

You must be root to run this command, and it is not permanent. You will have to run this every time you restart the server.

0
source

All Articles