Add minecraft documentation

This commit is contained in:
Justin Chung 2023-05-27 11:47:32 -04:00
parent 25fee88b5b
commit ef37a4b21c
No known key found for this signature in database
1 changed files with 88 additions and 0 deletions

88
docs/minecraft.md Normal file
View File

@ -0,0 +1,88 @@
# Minecraft
You may want to use host your own Minecraft server on your CSC VM. Here's a high-level guide on things you want to know. It should include most things you would want to know when setting up your server(s) but it will not replace documentation for the Minecraft servers, Minecraft proxy, reverse proxy, etc. that you want to use.
## Prerequisites
- A running CSC VM
- Working knowledge with SSH
- Recommended for reverse proxy: Access to a general-use machine (such as [HFCS](https://wiki.csclub.uwaterloo.ca/Machine_List#high-fructose-corn-syrup))
## Instructions
Depending on what your particular Minecraft server setup is, you may need more or less CPU and RAM. You'll need to access your CSC VM via SSH.
Next, consider the whole Minecraft server setup:
- What minecraft server(s) do you want? (e.g. vanilla, paper, spigot, fabric, etc.)
- Do you need a Minecraft proxy (e.g. Velocity, Waterfall, Bungeecord)?
- You'll likely want to be able to access it from the internet so you'll need to a TCP reverse proxy (e.g. HAProxy) as requests to open TCP ports in public campus firewall is very strict.
### Minecraft Server
Once you've chosen your Minecraft server, start it up (there are plenty tutorials to learn to do so online).
As of May 2023, I personally suggest using [Paper](https://papermc.io/) server ran on GraalVM Enterprise JVM (which could be obtained for free). Note that only GraalVM's enterprise version has the optimizations you want compared to the community version.
There's also a great [guide](https://github.com/brucethemoose/Minecraft-Performance-Flags-Benchmarks) on what Java JVM flags you want to use to start your Minecraft server with.
Keep note of the port of your server which you'll need later (default is `25565/tcp`).
**IMPORTANT:** Note that your Minecraft server hosted on a CSC VM will be accessible by anybody in campus network by default unless you configure your network settings, install a firewall, etc.
### Minecraft Proxy
If you need a Minecraft proxy, for supporting multiple Minecraft servers for example, popular options include [Velocity](https://docs.papermc.io/velocity/), [Waterfall](https://docs.papermc.io/waterfall/) and [Bungeecord](https://github.com/SpigotMC/BungeeCord).
As of May 2023, I personally suggest Velocity due to performance reasons and because it has Paper-specific servers.
**IMPORTANT:** Make sure your Minecraft proxy setup is safe!
For instance, for any Minecraft proxy, it's expected that any users cannot access the servers behind the proxy as that is likely a huge security loophole (e.g. if your server has authentication in a lobby server but players could access your creative server).
There are various things you could do to keep your Minecraft servers (plural since you have a proxy so you'll likely have more than one server). The [Velocity documentation](https://docs.papermc.io/velocity/security) has some recommendations.
Here are specific suggested options for possible setups on CSC cloud:
- Simplest: Have all your Minecraft servers and Minecraft proxy hosted on one CSC VM which has a firewall installed. Only open the port to your Minecraft proxy
- Complicated: Have Minecraft servers and proxy hosted on separate CSC VMs and secure it's connection on a Wireguard network (you're on your own for this although a few people may have some knowledge on syscom channel)
### Reverse Proxy
Unlike the Minecraft proxy, which you may not need for your setup, the recommended way to access your Minecraft server from the internet is configuring a TCP reverse proxy on a general-use CSC machine (as it has some ports opened to the internet).
#### Steps
1. Choose a TCP proxy
1. There are many options but HAProxy is a good option.
2. Download the binary of TCP proxy onto the general-use machine
1. Note that since CSC members do not have root access to general-use machines, you cannot download the proxy from package manager nor save proxy configs in root folders such as `/etc`.
2. You could download the TCP proxy of your choice from the internet straight onto the general-use machine using a CLI tool like `wget`. Alternatively, build a binary straight on the server.
3. If you choose to use HAProxy, there is an example configuration to use.
3. Configure the TCP proxy
1. Use a port that's [allowed on the general-use machine](https://wiki.csclub.uwaterloo.ca/Firewall#General_Use).
1. Make sure port is not being used by other CSC members on that general-use machine.
2. You could run `netstat -tln | grep <port>` to see if any existing programs are listening to the TCP port you want to use
2. Example HAProxy configuration (replace `vm_ip` with your CSC VMs IP hosting your Minecraft proxy or single Minecraft server and `port` with the reverse proxy port on general-use machine)
```
defaults
timeout connect 5000ms
timeout client 10000ms
timeout server 10000ms
frontend minecraft
mode tcp
option tcplog
default_backend mc-server
bind 0.0.0.0:<port>
backend mc-server
mode tcp
server mc <vm_ip>:25565 maxconn 100
```
Credit: Thanks Amolven for providing this config!
3. Start the TCP proxy with that config
### Last Step
Test your Minecraft server setup! Make sure you're able to connect to the reverse proxy, Minecraft proxy or Minecraft server IP/port with your Minecraft client. If you have a Minecraft proxy, it's also worth making sure you aren't able to connect to your Minecraft servers behind the proxy with your client from within campus network. If you are physically off campus, you'll have to connect to [IST's campus VPN](https://uwaterloo.atlassian.net/wiki/spaces/ISTKB/pages/262012980/Virtual+Private+Network+VPN) before verifying.