Skip to content

Instantly share code, notes, and snippets.

@stephankoelle
Created June 17, 2025 09:46
Show Gist options
  • Select an option

  • Save stephankoelle/7c97c2229dec1fee36c6f815f6216b58 to your computer and use it in GitHub Desktop.

Select an option

Save stephankoelle/7c97c2229dec1fee36c6f815f6216b58 to your computer and use it in GitHub Desktop.
minimal caddy file with podlet & quadlet

caddyfile

Define both domains and obtain certificates

www.abc.com, abc.com {
    # Redirect www to the bare domain
    @www {
        host www.abc.com
    }
    redir @www https://abc.com{uri}

    # Reverse proxy for the bare domain
    reverse_proxy :8080
}

howto podlet & quadlet for caddy:

0. Allow non-root privileged ports

in /etc/sysctl.d/51-caddy.conf
+net.ipv4.ip_unprivileged_port_start=1

+loginctl enable-linger
#https://mo8it.com/blog/quadlet/

1. create rootless quadlet location

mkdir -p  ~/.config/containers/systemd/

2. Use podlet (in container) to generate quadlet, redirect output to correct file:

podman run ghcr.io/containers/podlet --install  podman run --restart always --rm   --net=host -v caddy_data:/data -v caddy_config:/config -v ./caddyfile:/etc/caddy/Caddyfile:Z  docker.io/caddy > ~/.config/containers/systemd/caddy.container
## 3. make rebootable ``` [Service] Restart=always

[Install] #multiuser is wrong, you need default.target WantedBy=default.target

</del>

## 3. reload and start systemd service

systemctl --user daemon-reload systemctl --user start caddy.service => not needed! => systemctl --user enable caddy.service systemctl --user status caddy.service


## 4. read the log

journalctl --user -u caddy.service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment