Setting up a Minecraft Bedrock Server with Traefik Proxy

Setting up a Minecraft Bedrock server can be exciting, allowing you and your friends to dive into limitless digital worlds together. However, making it accessible from the internet while maintaining security and manageability can introduce complexities, especially when using a reverse proxy like Traefik. This guide will walk you through configuring Traefik to proxy a Minecraft Bedrock server, ensuring smooth connections and a more organized server setup.

Minecraft Bedrock Edition primarily uses UDP for communication on port 19132. Unlike web applications that rely on HTTP and TCP, Bedrock’s UDP nature requires a different approach when configuring Traefik. Traefik, known for its proficiency in handling HTTP traffic, can also manage TCP and UDP, making it a versatile choice for proxying various applications, including game servers.

To get your Minecraft Bedrock server working behind Traefik, you need to configure Traefik to handle UDP traffic correctly. Here’s how you can set up your traefik.yml configuration file:

entryPoints:
  http:
    address: ":80"
  https:
    address: ":443"
  udpminecraft:
    address: ":19132/udp"

This configuration defines an entry point named udpminecraft specifically for UDP traffic on port 19132. It’s crucial to specify /udp to ensure Traefik correctly interprets this entry point as UDP. You also need to ensure that your Docker Compose file for Traefik exposes the UDP port:

ports:
  - "80:80"
  - "443:443"
  - "19132:19132/udp"

Make sure that the UDP port 19132 is exposed in your Traefik Docker service definition. Now, let’s look at the Docker Compose configuration for your Minecraft Bedrock server. Here’s an example of how you might configure your docker-compose.yml for the Minecraft server:

version: '3'
services:
  minecraft:
    image: toasterlint/minecraft_bedrock
    ports:
      - "19132:19132/udp"
    labels:
      - "traefik.enable=true"
      - "traefik.udp.routers.minecraft.entrypoints=udpminecraft"
      - "traefik.udp.services.minecraft.loadbalancer.server.port=19132"
    environment:
      EULA: "TRUE"

In this Docker Compose configuration, we are defining a service for your Minecraft Bedrock server using the toasterlint/minecraft_bedrock image. The crucial part here is the labels section, which instructs Traefik on how to handle traffic for this service.

  • traefik.enable=true: This label tells Traefik to include this service in its configuration.
  • traefik.udp.routers.minecraft.entrypoints=udpminecraft: This defines a UDP router named minecraft and assigns it to the udpminecraft entry point we configured in traefik.yml.
  • traefik.udp.services.minecraft.loadbalancer.server.port=19132: This defines a UDP service named minecraft and specifies that the traffic should be forwarded to port 19132 on the Minecraft server container.

It’s important to note that unlike HTTP proxies, UDP proxies do not operate on domains in the same way. Minecraft Bedrock clients typically connect using IP addresses or server names resolved through other means (like in-game friend lists or direct IP connection). Therefore, you won’t be using a Host rule like you would for HTTP. The configuration above focuses on routing UDP traffic arriving at the udpminecraft entry point to your Minecraft server container.

By setting up Traefik in this manner, you are effectively creating a UDP proxy that forwards external connections on port 19132 to your Minecraft Bedrock server. This setup allows you to manage your server’s accessibility through Traefik without needing to expose the Minecraft server port directly to the internet, providing a layer of management and potential future integrations. Remember to adjust firewall settings to allow UDP traffic on port 19132 to reach your Traefik server.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *