zeekayandHanzo Dev 0cb3219776 fix(docker): golang base -> 1.26.5, the version go.mod requires (and the latest)
go.mod declares `go 1.26.5` while the builder pinned a much older golang image.
The golang images set GOTOOLCHAIN=local, so the base can never fetch a newer
toolchain and the build dies at once:

    go: go.mod requires go >= 1.26.5 (running go 1.x; GOTOOLCHAIN=local)

1.26.5 is also the current release — go.dev lists it as the newest stable, and
golang:latest and golang:1.26.5 are the same image (sha256:3aff6657219a4d9).

Image variant preserved; the target tag was verified to exist before the change.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-27 19:15:05 -07:00
2026-07-27 15:43:42 -07:00

simple-coredns-manager

A lightweight web UI for managing CoreDNS configuration files. Edit your Corefile and BIND zone files with diff preview, then reload CoreDNS with one click.

Note: This project was fully generated by Claude Opus 4.6 (Anthropic's AI model) via Claude Code as an experiment in AI-driven software development. No human-written code.

Originally built for the infrastructure part of MWIT-LINK (Mahidol Wittayanusorn School) to manage internal DNS records.

Features

  • Corefile editor — Edit your CoreDNS Corefile in a web-based editor with syntax-aware textarea
  • Zone file management — Create, edit, and delete BIND zone files (db.example.com format) with support for A, AAAA, CNAME, MX, TXT, and NS records
  • SOA auto-management — SOA serial auto-increments (YYYYMMDDNN format) on every save
  • Diff preview — See unified diffs of your changes before saving (powered by HTMX)
  • One-click reload — Send SIGUSR1 to CoreDNS container to pick up config changes
  • Master password auth — Simple single-password login with bcrypt + JWT cookie sessions
  • Docker-native — Runs alongside CoreDNS sharing config volumes, communicates via Docker socket
  • Graceful degradation — Works without Docker socket (reload features disabled)
  • OctoDNS compatible — Standard BIND zone files work with octodns-bind out of the box

Screenshots

The UI uses Bootstrap 5 with dark theme. Pages include a dashboard with CoreDNS status, a Corefile editor with diff preview, and a zone file manager with typed DNS records.

Quick Start

git clone https://github.com/modanub/simple-coredns-manager.git
cd simple-coredns-manager
docker compose up --build

Open http://localhost:8080 and log in with password changeme.

Configuration

All configuration is via environment variables:

Variable Default Description
COREFILE_PATH (required) Path to the CoreDNS Corefile
ZONE_DIR Corefile directory Directory containing zone files (db.*)
MASTER_PASSWORD (required) Plaintext or bcrypt hash (auto-detected by $2a$/$2b$ prefix)
JWT_SECRET (required) Secret key for signing JWT session tokens
COREDNS_CONTAINER_NAME coredns Docker container name for CoreDNS
PORT 8080 HTTP listen port

HOSTS_DIR is accepted as a fallback for ZONE_DIR for backward compatibility.

Using a pre-hashed password

# Generate a bcrypt hash
htpasswd -nbBC 12 "" 'your-password' | cut -d: -f2

# Use it directly
MASTER_PASSWORD='$2b$12$...'

Docker Compose

The included docker-compose.yml runs CoreDNS and the manager side by side:

services:
  coredns:
    image: coredns/coredns:latest
    container_name: coredns
    restart: unless-stopped
    ports:
      - "53:53/udp"
      - "53:53/tcp"
    volumes:
      - ./config/coredns:/etc/coredns
    command: -conf /etc/coredns/Corefile

  coredns-manager:
    build: .
    container_name: coredns-manager
    restart: unless-stopped
    ports:
      - "8080:8080"
    environment:
      - COREFILE_PATH=/etc/coredns/Corefile
      - ZONE_DIR=/etc/coredns
      - MASTER_PASSWORD=changeme
      - JWT_SECRET=change-this-secret
      - COREDNS_CONTAINER_NAME=coredns
    volumes:
      - ./config/coredns:/etc/coredns
      - /var/run/docker.sock:/var/run/docker.sock:ro
    depends_on:
      - coredns

Architecture

simple-coredns-manager/
├── main.go                          # Entry point, route registration
├── internal/
│   ├── config/config.go             # Environment variable loading
│   ├── auth/
│   │   ├── auth.go                  # bcrypt verify, JWT generation, cookies
│   │   └── middleware.go            # JWT auth middleware (redirect on fail)
│   ├── docker/docker.go             # Container discovery + SIGUSR1 reload
│   ├── coredns/
│   │   ├── corefile.go              # Read/write/validate Corefile (atomic writes)
│   │   ├── zone.go                  # Zone file CRUD with SOA serial management
│   │   └── diff.go                  # Unified diff generation
│   ├── handlers/                    # HTTP handlers (dashboard, corefile, zones, etc.)
│   └── templates/renderer.go        # Go html/template renderer for Echo
├── templates/                       # HTML templates (Bootstrap 5 + HTMX)
├── config/coredns/                  # Example CoreDNS configuration
├── Dockerfile                       # Multi-stage build (~15-20MB image)
└── docker-compose.yml

Tech Stack

Component Choice
Backend Go + Echo v4
Frontend Bootstrap 5 + HTMX (both via CDN)
Auth bcrypt + JWT (httpOnly cookie)
DNS parsing miekg/dns
Docker Docker Engine SDK
Diff gotextdiff

Security

  • Atomic file writes — Write to temp file, then os.Rename to prevent corrupt configs
  • Path traversal protection — Domain names validated against [a-zA-Z0-9.-] regex
  • Zone file validation — Zone files parsed with miekg/dns before saving (SOA required)
  • CSRF protection — Echo CSRF middleware with token in form fields and HTMX header
  • Rate limiting — Login endpoint limited to 5 burst / 1 req/sec per IP
  • httpOnly cookies — JWT stored in httpOnly, SameSite=Strict cookies
  • Concurrent write safety — sync.RWMutex protects file operations

Development

# Run locally (requires Go 1.23+)
export COREFILE_PATH=./config/coredns/Corefile
export ZONE_DIR=./config/coredns
export MASTER_PASSWORD=dev
export JWT_SECRET=dev-secret
go run .

License

MIT

S
Description
Lightweight web UI for managing CoreDNS configuration — edit Corefile & host files with diff preview, one-click reload via Docker. Built for MWIT-LINK.
Readme MIT
98 KiB
Languages
Go 59.3%
HTML 39.7%
Dockerfile 0.6%
DIGITAL Command Language 0.4%