ngrok + Cloudflare solution to run a public Minecraft server without exposing your home network.
271
This service ensures that your Minecraft server running on a dynamic IP address remains accessible to players. It leverages ngrok to expose your local Minecraft server to the internet and jq to parse the ngrok public URL. It then updates the DNS records on Cloudflare, allowing players to connect to your server using a friendly domain name instead of a numeric IP address.
Us this to run a public Minecraft server without exposing your home network.
This setup is based on this article by Oliver Bravery.
_minecraft, and the protocol is tcp, since this is what Minecraft will be looking for.mc as the subdomain, _minecraft as the service, and the protocol is tcp, connect to mc.example.com in Minecraft.If you prefer to run the ngrok Minecraft service directly using Docker without building, you can use the following docker run command:
docker run -d --name ngrok-tunnel \
-p 4040:4040 \
--env NGROK_AUTHTOKEN=<YOUR_AUTHTOKEN> \
--env MINECRAFT_PORT=25565 \
--env CLOUDFLARE_ZONE_ID=<YOUR_ZONE_ID> \
--env CLOUDFLARE_DNS_RECORD_ID=<YOUR_DNS_RECORD_ID> \
--env CLOUDFLARE_API_TOKEN=<YOUR_API_TOKEN> \
--restart unless-stopped \
crisdias/ngrok-minecraft
Replace the placeholder values (<YOUR_AUTHTOKEN>, <YOUR_ZONE_ID>, <YOUR_DNS_RECORD_ID>, <YOUR_API_TOKEN>) with your actual ngrok and Cloudflare credentials.
This command will start the ngrok container and set it to restart unless explicitly stopped.
For those who prefer using docker-compose, here is an example docker-compose.yml that includes both the Minecraft server and the ngrok service:
version: '3.8'
services:
mc:
image: itzg/minecraft-server
environment:
EULA: "TRUE"
ports:
- "25565:25565"
volumes:
- mc_data:/data
ngrok:
container_name: ngrok-tunnel
image: crisdias/ngrok-minecraft
ports:
- 4040:4040
environment:
- NGROK_AUTHTOKEN=<YOUR_AUTHTOKEN>
- MINECRAFT_PORT=25565
- CLOUDFLARE_ZONE_ID=<YOUR_ZONE_ID>
- CLOUDFLARE_DNS_RECORD_ID=<YOUR_DNS_RECORD_ID>
- CLOUDFLARE_API_TOKEN=<YOUR_API_TOKEN>
restart: unless-stopped
depends_on:
- mc
volumes:
mc_data:
Save this as docker-compose.yml and run with docker compose up -d.
Remember to replace the placeholders with your actual data and agree to the Minecraft EULA by setting EULA to TRUE if you agree.
NGROK_AUTHTOKEN: Your ngrok authentication token.MINECRAFT_PORT: The local port where your Minecraft server is running.CLOUDFLARE_ZONE_ID: The zone ID of your domain on Cloudflare.CLOUDFLARE_DNS_RECORD_ID: The ID of the DNS record you wish to update.CLOUDFLARE_API_TOKEN: Your Cloudflare API token.Please follow the instructions here to create a Cloudflare API token and SRV record.
This project is open-sourced under the MIT License. See the LICENSE file for more details.
Content type
Image
Digest
sha256:fcc78ed35…
Size
32.7 MB
Last updated
almost 3 years ago
docker pull crisdias/ngrok-minecraft