Docker DirectSlave for DirectAdmin

Docker DirectSlave
Docker DirectSlave

Introduction

If you manage DirectAdmin server(s), you need secondary DNS server(s) to stabilize your DNS system. In this tutorial, I will show you how to quickly set up a secondary DNS server with DirectSlave using docker and also configure ACME for DirectSlave's SSL automation.

Prerequisites

  • A Debian/Ubuntu server for running DirectSlave.
  • Linux basic knowledge.
  • Basic understanding of docker.

Step-by-step Guide

I've created a DirectSlave docker image that includes BIND 9, a full-featured DNS system. So, we need two docker volumes: one for BIND 9 and the other for DirectSlave.

I am using DNS API with Cloudflare for getting the certificates, but you can use whatever methods you like.

  1. SSH to your server and install Docker: For more information, see Install Docker Engine.

  2. Create a docker-compose.yaml file with the following content: Say you want to use the domain secondary.domain.com for your DirectSlave server; here is the docker-compose file:

    volumes:
      data:
        driver: local
      directslave:
        driver: local
    
    services:
      directslave:
        restart: unless-stopped
        image: powerkernel/directslave
        container_name: directslave
        labels:
          sh.acme.autoload.domain: secondary.domain.com
        environment:
          - USER=someuser
          - PASSWD=verySecurePassword
        ports:
          - target: 2222
            published: 2222
            protocol: tcp
          - target: 53
            published: 53
            protocol: tcp
          - target: 53
            published: 53
            protocol: udp
        volumes:
          - directslave:/usr/local/directslave
          - data:/var/lib/bind/slave
      acme.sh:
        image: neilpang/acme.sh
        container_name: acme.sh
        command: daemon
        restart: unless-stopped
        volumes:
          - ./acmeout:/acme.sh
          - /var/run/docker.sock:/var/run/docker.sock
        environment:
          - CF_Token=xxxx
          - CF_Account_ID=yyyy
          - CF_Zone_ID=zzzz
          - DEPLOY_DOCKER_CONTAINER_LABEL=sh.acme.autoload.domain=secondary.domain.com
          - DEPLOY_DOCKER_CONTAINER_KEY_FILE="/usr/local/directslave/ssl/key.pem"
          - DEPLOY_DOCKER_CONTAINER_CERT_FILE="/usr/local/directslave/ssl/cert.pem"
          - DEPLOY_DOCKER_CONTAINER_CA_FILE="/usr/local/directslave/ssl/ca.pem"
          - DEPLOY_DOCKER_CONTAINER_FULLCHAIN_FILE="/usr/local/directslave/ssl/fullchain.pem"
          - DEPLOY_DOCKER_CONTAINER_RELOAD_CMD="chown -R bind:bind /usr/local/directslave && /usr/bin/supervisorctl restart directslave"
    
  3. Finally, go to your DirectAdmin server and configure the Multi Server Setup with your DirectSlave: DirectAdmin Multi Server

Conclusion

With this all-in-one docker image, you can easily set up a DirectSlave DNS system for your DirectAdmin server(s). I have been using this for my production environments for years without any problem.

References

Comments