Minecraft Server using Cloudflared
Something that I have started using a lot more is Cloudflare's Tunnel. I have been using them mainly for securing SSH access to my servers as it means that I don't need to have any external ports open. Plus, Tunnels also offer a browse rendered SSH, which is convenient. In this guide I will walking through how to deploy a Minecraft Server that is securely accessed by a Tunnel.
- Domain on Cloudflare
- Cloudflared installed both on server and client machine. (I am using Docker in this tutorial).
Creating Server Config
The first thing to do is to create the cloudflared tunnel file and configuration file. To create the tunnel run
cloudflared tunnel create minecraft. Once the command completes then it will tell you the path to the tunnel JSON file. Copy that file as well as the
cert.pem into your current directory for convenience. For the cloudflared configuration file, you need something simple like:
1tunnel: <tunnel-id> 2credentials-file: <path/to/your/tunnel/file.json> 3ingress: 4 - hostname: mc.cyberjake.xyz 5 service: tcp://mc:25565 6 - service: http_status:404
Download Here. For those who are not using docker you likely going to want to replace
tcp://localhost:25565 or whatever the address that your Minecraft server is running on. For those who are using docker then there is a compose file available. Can confirm that your tunnel is working by running
cloudflared tunnel run --config </path/to/tunnel/config>.
To be able to connect to your server you need the client to proxy the connection. This can be done by running
cloudflared access tcp --hostname <url of your server> --url localhost:9210. Then open your minecraft client and go to multiplayer and add a new server then for the address use
localhost:9210. Then boom your server will be there to access.