dns – Prevent subdomains created for minecraft from directing to the webserver on the machine

When you point a subdomain at an IP address, that subdomain will be available for all protocols. When you point subdomains for Minecraft at this server that hosts both Minecraft and a web server, and HTTP and HTTPS requests for those Minecraft subdomains are going to hit the web server.

One way to prevent the subdomains from hitting the web server would be to host Minecraft and the web server on separate server. Presumably you would not want to use that solution because it would increase your costs significantly.

You could also get a second IP address for your server and configure your Minecraft server and your web server for the two IP addresses. Most web servers have the ability to choose which IP address for a machine they bind to. This would also incur some additional costs. (Extra IP addresses usually have cost with your hosting company.) Multicraft has a setting for which IP address to bind. You would point the Minecraft subdomain to one IP address, the Multicraft web server host name to the other IP address, and ensure that the web server is only bound to the one IP address.

The third solution is configuring virtual hosts. When a web browser connects to a web server at an IP address, it sends the host name it is connecting to. This allows the web server to behave differently for different host names (for example serving separate content for each host name.) In your case, you would use this virtual hosts to serve error pages for all but your one desired subdomain.

Unfortunately I don’t see any settings for virtual hosts in the multicraft settings. You would need to run an additional webserver that supports virtual hosts and use a reverse proxy to forward requests for just one virtual host to the multicraft web server which would run on some non-standard port. It is even possible that multicraft is already running this way. Their howto has references to some Apache configuration. Their security documentation has some additional references to Apache.

In any case you would need to:

  1. Run Apache on ports 80/443
  2. Run the standalone multicraft server on some other port (like 8080).
  3. Configure a default virtual host in Apache that shows an error page (like a 404 not found).
  4. Install and enable mod_proxy (the proxy module for Apache).
  5. Configure a virtual host with the reverse proxy. The Apache configuration would look something like:
<VirtualHost>
   # Because it comes first in the configuration file,
   # this virtual host is the "default" virtual host
   ServerName localhost
   # You would have to create this empty directory, 
   # or choose some other empty directory to use
   ServerRoot C:/xampp/htdocs/empty/
</VirtualHost>

<VirtualHost>
   ServerName multicraft.example.com
   ProxyPass "/" "http://localhost:8080/"
   ProxyPassReverse "/" http://localhost:8080/"
</VirtualHost>