basforge

Search titles, text and the “If it doesn’t work” cases.

    RU
    Path · Your own server

    Server profile

    Every recipe on the path follows these rules, so the levels fit together: the backup knows where the data and certificates are, monitoring knows which services to check, and git on the Migration level picks up the same paths.

    Your values

    Filled into the commands on this page and in every recipe on the path; stored in this browser only.
    Email
    [email protected]placeholder
    Domain
    example.orgplaceholder
    Server address
    203.0.113.10placeholder
    User
    example-userplaceholder
    Server name
    web1placeholder
    Backup server address
    198.51.100.20placeholder

    Without the script the commands show placeholder values: replace them with yours.

    Where things are

    /opt/                               stacks, one directory per stack
      traefik/                          the proxy: the only one listening on 80 and 443
        docker-compose.yaml
        data/traefik.yml                static config
        data/dynamic/                   shared middleware, TLS options
        data/acme.json                  Let's Encrypt certificates (600, not in git)
        data/logs/access.log            request log for every site
      memos/                            a service at memos.example.org
        docker-compose.yaml
        .env                            variables with secrets, when there's no other way (600, not in git)
        data/                           everything the service writes
      scripts/                          scripts for the whole server
    /srv/secrets/<stack>/               secrets as files: directory 700, file 400, owned by root
    
    network proxy — shared: Traefik and every service it exposes
    open to the outside — only 22, 80 and 443
    example-user logs in with a key, root can't log in over SSH

    Rules

    Stack
    /opt/<stack>/docker-compose.yaml — a directory of its own for every serviceThe directory name is the compose project name: move a stack without name: and it gets new, empty volumes (The compose project name), so pick the place once. On the Migration level /opt becomes a git repository, and the stacks go into it as they are (Server configs in git).
    Name
    one for everything: directory /opt/memos, container memos, Traefik router memos, address memos.example.orgA name from the log leads to the directory, the container and the address without opening the compose file. Spell the router name the same in every label: a typo raises no error, Traefik quietly creates a second router (Middleware on a missing router).
    Data
    /opt/<stack>/data/, in compose — ./data:…Everything a stack writes sits next to its compose file, so the backup on the Backups level doesn’t need to know about each service: it takes data/ of every stack. A named volume lives in /var/lib/docker under the project name; where you can’t do without one, give it an explicit name: (The compose project name).
    Secrets
    as a file in /srv/secrets/<stack>/ (a Docker secret) or in /opt/<stack>/.env with mode 600; git gets only .env.example with the names/srv/secrets lives outside /opt, so secrets end up neither in the git repository nor in a management panel that mounts /opt (Secrets in Docker stacks). Nor in the browser: passwords and tokens are generated by a command on the server, and “Your values” has no fields for them.
    Network
    proxy, external: create it once; Traefik and every service it exposes join itThe network is created apart from the stacks (external: true), so recreating Traefik doesn’t detach the services. Traefik reaches a container through proxy even when the container has a network of its own: traefik.yml says so (Traefik from scratch).
    Open ports
    only 22, 80 and 443; services have no ports:, they’re reached by name through TraefikA port published by Docker bypasses ufw (Docker ports bypass the input chain): a ports: line in a service’s compose file would open it to the whole internet. A port only the server needs goes on 127.0.0.1 (A host-only port goes on 127.0.0.1); reach it through an SSH tunnel (SSH tunnels). SSH stays on 22: changing the port cuts log noise but doesn’t protect anything (Port 22).
    User
    example-user with sudo, key login; root can’t log in over SSH; recipe commands run with sudoDon’t add the user to the docker group: through docker.sock it grants root without a password (Docker on Ubuntu). That’s why sudo comes before docker too, and a stolen SSH key still stands a password away from root.
    Request log
    /opt/traefik/data/logs/access.log, JSONOne file for every site on the server: CrowdSec reads it (CrowdSec with Traefik behind Cloudflare), and so does log collection (Traefik logs). Container logs stay in docker logs, their size is capped in daemon.json (Docker on Ubuntu).
    Scripts
    for the whole server — /opt/scripts/, for one stack — in its directoryA script sits next to what it serves and goes into git along with the stack (Server configs in git).

    A server not built from the recipes

    These commands show where your server is laid out differently. A difference isn’t an error, but the recipes on the path expect these paths and names: you’ll have to adjust their commands.

    sudo docker compose ls -a→ every stack shows /opt/<stack>/docker-compose.yaml under CONFIG FILES
    sudo docker network inspect proxy --format '{{range .Containers}}{{.Name}} {{end}}'→ traefik and the services reached by name
    sudo grep -l "^ *ports:" /opt/*/docker-compose.yaml→ only /opt/traefik/docker-compose.yaml; anywhere else ports: is on 127.0.0.1
    sudo ss -tlnH | awk '{print $4}' | grep -v -e '^127\.' -e '^\[::1\]'→ only :22, :80 and :443 listen on outside addresses
    sudo find /opt -maxdepth 2 -name .env ! -perm 600→ nothing: every .env has mode 600
    sudo sshd -T | grep -E '^(permitrootlogin|passwordauthentication) '→ permitrootlogin no and passwordauthentication no
    getent group docker→ docker:x:<number>: — nothing after the last colon, nobody in the group
    To the path map