Self Host Demo

This repository contains example code to host several simple services using Docker Compose with self-signed certification.

Services Included:

  • AdGuard Home: A network-wide ad and tracker blocking DNS server.
  • Caddy: A powerful, enterprise-ready, open-source web server with automatic HTTPS.
  • MockHTTP: A simple HTTP mock server for testing and development.

Self-Signed Certification

This demo utilizes self-signed certificates for local development and testing purposes. While this may cause browser warnings, it is suitable for demonstrating the services without requiring external certificate authorities.

Technology Stack

This project leverages the following technologies:

  • Docker & Docker Compose: For defining and running multi-container Docker applications.
  • Caddy: As the primary web server and for handling automatic HTTPS (with self-signed certificates in this setup).

Getting Started

To get these services up and running on your local machine, follow these steps:

  1. Clone the repository:

    git clone https://github.com/DanSnow/self-host-demo.git
    cd self-host-demo
  2. Install and configure mkcert (if needed): If you need to generate local trusted certificates, you can use mkcert.

    • Installation: Follow the instructions on the mkcert GitHub page for your operating system. For macOS, you can use Homebrew:

      brew install mkcert
      brew install nss # if using Firefox
    • Install local CA:

      mkcert -install
    • Copy certificates to Caddy data directory: Copy the generated root CA certificate and key to the caddy_data/certs directory, which is mounted by the Caddy service.

      cp "$(mkcert -CAROOT)/rootCA.pem" ./caddy_data/certs/
      cp "$(mkcert -CAROOT)/rootCA-key.pem" ./caddy_data/certs/
  3. Start the services:

    docker compose up -d

    This command will build (if necessary) and start all the services defined in compose.yml in detached mode.

  4. Access the services:

    • AdGuard Home: Typically accessible via http://localhost:3000 (check your compose.yml for exact port mapping).
    • Caddy: Accessible via http://localhost or https://localhost (depending on your Caddyfile configuration).
    • MockHTTP: Check your compose.yml for its exposed port.
  5. Stop the services: To stop and remove the containers, networks, and volumes created by up, run:

    docker compose down

Full article here (Tradition Chinese)