This repository contains example code to host several simple services using Docker Compose with self-signed certification.
- 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.
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.
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).
To get these services up and running on your local machine, follow these steps:
-
Clone the repository:
git clone https://github.com/DanSnow/self-host-demo.git cd self-host-demo -
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/certsdirectory, which is mounted by the Caddy service.cp "$(mkcert -CAROOT)/rootCA.pem" ./caddy_data/certs/ cp "$(mkcert -CAROOT)/rootCA-key.pem" ./caddy_data/certs/
-
-
Start the services:
docker compose up -d
This command will build (if necessary) and start all the services defined in
compose.ymlin detached mode. -
Access the services:
- AdGuard Home: Typically accessible via
http://localhost:3000(check yourcompose.ymlfor exact port mapping). - Caddy: Accessible via
http://localhostorhttps://localhost(depending on your Caddyfile configuration). - MockHTTP: Check your
compose.ymlfor its exposed port.
- AdGuard Home: Typically accessible via
-
Stop the services: To stop and remove the containers, networks, and volumes created by
up, run:docker compose down
Full article here (Tradition Chinese)