DiscoPanel

repository·main·Indexed 43 days ago

https://github.com/nickheyer/discopanel

A web-based Minecraft server, proxy, and modpack manager that uses Docker to isolate servers. It features a smart proxy system for running multiple servers behind a single port using custom hostnames and provides a REST API based on Protobuf definitions for server management.

Tokens
21.3K
Snippets
60
Records
96
Agent score
51%

What's inside DiscoPanel

  1. What is DiscoPanel?

    main

    DiscoPanel is a self-hosted, Docker-powered Minecraft server manager. It provides a web interface to manage the following core functionalities:

    • Server Management: Creation and lifecycle management of Minecraft servers.
    • Modpack Installation: Automated installation of modpacks.
    • Proxy Routing: Handling network routing for server access.
    • Backups: Managing server data backups.
    • Access Control: Multi-user access control and permissions via the web interface.
  2. Keycloak Realm Configuration Details

    main

    The default realm.json provided in oidc/keycloak/config/realm.json is imported automatically on first start via the --import-realm flag. It configures the following:

    • Client: discopanel (a confidential client using the standard authorization code flow).
    • Roles: admin and user realm roles.
    • Groups: admin and user groups. New users are added to the user group by default.
    • Protocol Mappers:
      • A groups mapper that places group membership into the groups claim on all tokens.
      • A realm-roles mapper for the roles claim.
    • Default User: An admin user with credentials admin / admin assigned to both admin and user groups.
  3. Map roles using Google OIDC claims

    main

    Google does not provide a groups claim in its OIDC tokens. You have two primary ways to handle roles:

    Standard Setup (Default Roles)

    Leave DISCOPANEL_AUTH_OIDC_ROLE_CLAIM empty. Users will be assigned DiscoPanel's default roles upon their first login. An existing admin can then promote them via the DiscoPanel UI.

    Google Workspace Domain Mapping

    If you use Google Workspace, you can map an entire domain to a specific role using the hd (hosted domain) claim. This is useful for automatically granting admin rights to your organization.

    Example Configuration:

    - DISCOPANEL_AUTH_OIDC_ROLE_CLAIM=hd
    - DISCOPANEL_AUTH_OIDC_ROLE_MAPPING={"yourdomain.com":"admin"}
  4. Configure Authelia OIDC settings

    main

    To ensure DiscoPanel can correctly authenticate and map roles, configure the following sections in Authelia's configuration.yml:

    • identity_providers.oidc.clients: Define the DiscoPanel OIDC client. Note that the client_secret in this file must be a PBKDF2-SHA512 hash of the plaintext secret used in your DiscoPanel environment variables.
    • claims_policies.discopanel: Configure this to put groups directly in the ID token. This allows DiscoPanel to read roles without requiring a separate UserInfo call.
    • identity_providers.oidc.jwks: Contains the RSA key pair used for signing tokens. For production, you should generate your own keys.
    • session.cookies.domain: This must match the domain used in DISCOPANEL_AUTH_OIDC_ISSUER_URI. For development, the default is traefik.me.
  5. Production hardening for Authelia OIDC

    main

    The default Authelia/DiscoPanel configuration is intended for development only. Before deploying to production, perform the following steps:

    • TLS/SSL: Replace self-signed tls.crt and tls.key with real certificates and set DISCOPANEL_AUTH_OIDC_SKIP_TLS_VERIFY=false.
    • Secrets: Change all sensitive values, including the HMAC secret, session secret, storage encryption key, JWT reset secret, and the OIDC client secret (both the hash in configuration.yml and the plaintext in the DiscoPanel compose file).
    • JWKS: Generate a new RSA key pair for identity_providers.oidc.jwks in configuration.yml.
    • Domains: Update session.cookies.domain in Authelia and all localhost entries in DISCOPANEL_AUTH_OIDC_REDIRECT_URL to your actual production domain.
    • Authentication: Optionally set DISCOPANEL_AUTH_LOCAL_ENABLED=false to force OIDC-only login.
  6. Map Discord roles to DiscoPanel roles

    main

    To translate Discord roles directly into DiscoPanel roles, you must use the guild member endpoint. This requires your Discord application to be installed in the server as a bot.

    1. Add guilds.members.read to your DISCOPANEL_AUTH_OIDC_SCOPES.
    2. Use the Discord invite link (OAuth2 → URL Generator → select bot) to add your app to the server.
    3. Configure the following environment variables:
    - DISCOPANEL_AUTH_OIDC_SCOPES=openid,identify,email,guilds.members.read
    - DISCOPANEL_AUTH_OIDC_EXTRA_CLAIMS_URL=https://discord.com/api/users/@me/guilds/YOUR_GUILD_ID/member
    - DISCOPANEL_AUTH_OIDC_EXTRA_CLAIMS_KEY=roles
    - DISCOPANEL_AUTH_OIDC_EXTRA_CLAIMS_NAME=discord_roles
    - DISCOPANEL_AUTH_OIDC_ROLE_CLAIM=discord_roles
    - DISCOPANEL_AUTH_OIDC_ROLE_MAPPING={"DISCORD_ROLE_ID":"admin","OTHER_ROLE_ID":"moderator"}
    - DISCOPANEL_AUTH_OIDC_REJECT_UNMAPPED=true

    Key Details:

    • EXTRA_CLAIMS_KEY=roles pulls the roles array from the Discord member response.
    • DISCOPANEL_AUTH_OIDC_ROLE_MAPPING maps Discord Role IDs to DiscoPanel role names.
    • DISCOPANEL_AUTH_OIDC_REJECT_UNMAPPED=true ensures users without a matching role are denied access.
    • Non-members are automatically rejected as the Discord API returns a 403 for non-members.
  7. Restrict DiscoPanel access to a specific Discord server

    main

    To prevent any Discord user from logging in and instead restrict access to members of a specific server, use the extra claims mechanism to fetch guild membership data.

    1. Add guilds to your DISCOPANEL_AUTH_OIDC_SCOPES.
    2. Configure the following environment variables:
    - DISCOPANEL_AUTH_OIDC_SCOPES=openid,identify,email,guilds
    - DISCOPANEL_AUTH_OIDC_EXTRA_CLAIMS_URL=https://discord.com/api/users/@me/guilds
    - DISCOPANEL_AUTH_OIDC_EXTRA_CLAIMS_KEY=#.id
    - DISCOPANEL_AUTH_OIDC_EXTRA_CLAIMS_NAME=guilds
    - DISCOPANEL_AUTH_OIDC_REQUIRED_CLAIM=guilds
    - DISCOPANEL_AUTH_OIDC_REQUIRED_VALUES=YOUR_GUILD_ID

    Replace YOUR_GUILD_ID with your Discord server's ID. The EXTRA_CLAIMS_KEY uses gjson path syntax (#.id) to extract IDs from the array returned by Discord.

  8. Deploy DiscoPanel using Docker Compose

    main

    The recommended way to run DiscoPanel is via Docker Compose. This requires Docker Engine with Docker Compose installed, as DiscoPanel manages Minecraft servers as Docker containers.

    1. Create a docker-compose.yml file (you can use the one provided in the repository).
    2. Spin up the service using the following command:
    docker compose up -d

    Once the service is running, access the interface at http://<your-host>:8080 to create your admin account.

  9. Install DiscoPanel in a Proxmox LXC container

    main

    You can deploy DiscoPanel in a Debian 13 LXC container using the Proxmox VE Community Scripts helper script. This script automates the installation of Docker, Go, Node.js, and builds DiscoPanel from source, managing it as a systemd service.

    Run the following command from your Proxmox host shell to start the interactive installation wizard:

    bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/discopanel.sh)"
  10. Quick Start: Build and run from source

    main

    To build DiscoPanel from source, you need Go (v1.24.5+) and NodeJs + npm. Follow these steps to clone, generate API code, build the frontend, and compile the backend:

    1. Clone the repository.
    2. Generate RPC/API code using buf in Docker.
    3. Build the frontend using npm.
    4. Build the Go backend (which embeds the frontend).
    5. Run the binary.

    For development, you can use make gen and make dev if you have make installed.

    # Clone it
    git clone https://github.com/nickheyer/discopanel
    cd discopanel
    
    # Generate the rpc/api code for server/client using buf in docker
    docker run --rm -v "$(pwd):/workspace" -w /workspace -u "$(id -u):$(id -g)" bufbuild/buf:latest generate
    
    # Get npm deps and build frontend first
    cd web/discopanel && npm install && npm run build && cd ../..
    
    # Build backend and embed front end
    go build -o discopanel cmd/discopanel/main.go
    
    # Run it
    ./discopanel
    
    # Open it
    # http://localhost:8080
  11. Run DiscoPanel with Docker

    main

    You can run DiscoPanel as a standalone Docker container. Ensure you mount the Docker socket to allow DiscoPanel to manage Minecraft server containers, and map your data/backup directories correctly.

    docker run -d \
      --name discopanel \
      --restart unless-stopped \
      --network host \
      -v /var/run/docker.sock:/var/run/docker.sock \
      -v ./data:/app/data \
      -v ./backups:/app/backups \
      -v ./tmp:/app/tmp \
      -v ./config.yaml:/app/config.yaml:ro \
      -e DISCOPANEL_DATA_DIR=/app/data \
      -e DISCOPANEL_HOST_DATA_PATH="$(pwd)/data" \
      -e TZ=UTC \
      nickheyer/discopanel:latest