Setting Up Local HTTPS Services with Custom Domains Using Caddy on Arch Linux


#local #web #configuration #container

This guide explains how to serve multiple local services on custom domains (e.g. .local β†’ service1.local) with HTTPS, using Caddy and no external DNS or certificates.


🧱 Prerequisites


πŸ”§ Step 1: Map Local Hostnames

Edit /etc/hosts:

sudo nano /etc/hosts

Add:

127.0.0.1  service1.local service2.local service3.local

πŸ“ Step 2: Configure Caddyfile

Edit or create your Caddyfile (default path: /etc/caddy/Caddyfile):

service1.local {
    tls internal
    reverse_proxy 127.0.0.1:8080
}

service2.local {
    tls internal
    reverse_proxy 127.0.0.1:9090
}

This tells Caddy to:


πŸš€ Step 3: Start Caddy

Restart the service to apply changes:

sudo systemctl restart caddy

πŸ” Step 4: Trust Caddy’s Local CA (One-Time Setup)

1. Copy the root certificate:

sudo cp /var/lib/caddy/pki/authorities/local/root.crt /etc/ca-certificates/trust-source/anchors/caddy-local.crt

2. Update the system trust store:

sudo trust extract-compat

3. (Optional) Trust in Firefox:


βœ… Done!

Now you can access:

All with trusted HTTPS, locally.

Back to the top ↑