3

So I have my own windows server, and on it I am using Multicraft to host multiple Minecraft servers. I have also purchased a domain through google. I have a subdomain set up for each Minecraft server instance on different ports, as well as a subdomain for the Multicraft webserver. All domains work fine, but my issue is I only want multicraft.example.com to direct to the webserver, however all other subdomains when put into a web browser instead of Minecraft also direct to the Multicraft panel.

I've looked at Forwarding a subdomain to a Minecraft Server but it does not answer my issue. I have the pointers already working with A records and SRV records for the webserver and Minecraft server. But because they're on the same IP, every subdomain for a Minecraft server points to the webserver. I only want the webserver domain to point to the webserver. Not the Minecraft subdomains.

0

1 Answer 1

0

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>
3
  • Thank you. I will attempt that later tonight after work. I will give updates. Commented Jun 11, 2021 at 19:58
  • I kind of got it to work. I didn't go the approach of running another instance of apache. I instead just changed the two httpd.conf files located in the apache2 directory of Multicraft and Multicraft config directory, and allowed it to only listen on port 8080. So that way any of my subdomains when in web browser all point to 80, nothing is there to respond. I may go as far as adding another apache instance for the purpose of redirect, since I eventually would like to host possibly two other sites on my server. Thank you for your help and pointing me in the right direction. Commented Jun 12, 2021 at 4:53
  • Minecraft clients do honour SRV records (where HTTP clients do not). Hence you can easily signal them to connect to any arbitrary server on the host, hence no need of any other IP or machine. Commented May 17, 2022 at 1:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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