Minecraft Cloudflare exposes your Minecraft server to the public without portforwarding using Cloudflare and ngrok. It automatically updates your Cloudflare's DNS record (SRV) to point to the newly generated url of ngrok.
Note Make sure you have Node preinstalled
-
Create your
.envfrom .env.example -
Install all the dependencies
npm install- Run the application
npm run build-startPlease see the docker-compose.yml as an example.
services:
minecraft-cloudflare:
image: alecblance/minecraft-cloudflare:1.1.1
container_name: minecraft-cloudflare
ports:
- 5000:5000
environment:
- NGROK_AUTH_TOKEN=${NGROK_AUTH_TOKEN}
- MINECRAFT_SERVER_PORT=${MINECRAFT_SERVER_PORT}
- CLOUDFLARE_API_KEY=${CLOUDFLARE_API_KEY}
- CLOUDFLARE_ZONE_ID=${CLOUDFLARE_ZONE_ID}
- CLOUDFLARE_EMAIL=${CLOUDFLARE_EMAIL}
- SUBDOMAIN_TO_UPDATE=${SUBDOMAIN_TO_UPDATE}
- MINECRAFT_CLOUDFLARE_SERVER_PORT=${MINECRAFT_CLOUDFLARE_SERVER_PORT}
restart: unless-stoppedIt runs ngrok which forwards the ip:port or just port of the Minecraft server, then extracts the url and edits the SRV of your Cloudflare zone. It is actually simple, yet a boring manual task if you do restarts 😮💨.
I was planning to host a minecraft server, but we don't have an option to do portforwarding. Having knowledge on Cloudflare tunnels, I thought it will just be a breeze, however it doesn't support minecraft's tcp so we are forced to use ngrok. Manually changing records is tiresome, so why not create another docker container that automates these. 🥹✨
Well, of course! 😎 Feel free to contact me or do a PR. I'll review it and if it is good and valuable, I'll merge it right away.
Client: NodeJS
Libraries: cloudflare, ngrok
