basforge

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

    RU
    Path · Linux, Docker, Homelab

    Your own server

    From an empty VPS to a server that installs its own updates, bans brute force, reports failures, keeps backups off the server, and moves to a new VPS from git and a backup. One server for the whole path: each level starts where the previous one ended.

    Levels

    1. Observability

      You can see what’s going on, and the server reports when something is wrong.

      RecipeMetrics, uptime checks and alerts
      Tips for this level
      • An alert when a job didn’t run
      • OnFailure= for systemd services
      • A WAF with CrowdSec AppSec
    2. Migration

      The whole server or some of its stacks come up on a new VPS from git and a backup — after a failure, when changing hosts, or when the server can’t keep up.

      RecipeMoving to a new server
      Tips for this level
    3. Automation

      Updates and deploys run on their own, without logging in over SSH.

      RecipeDeploy without SSH
      Tips for this level
      • CI builds the image, the server pulls it from a registry
      • Renovate watches image versions
      • systemd timers instead of cron
      • A script that git replaces mid-run
      • Why not SSH from GitHub Actions

    Dashed means not written yet: the map shows everything a server of your own can have, not just what’s done. A white tip exists, a dashed one is coming.

    Already have a server: where to pick up

    The “Done when” checks from the recipes. Run them on your server and mark what passes — the level to continue from shows up below. Marks stay in this browser only.

    1Base
    sudo sshd -T | grep -E '^(permitrootlogin|passwordauthentication) '→ permitrootlogin no and passwordauthentication no
    sudo ufw status | head -1→ Status: active
    apt-config dump | grep -E 'Automatic-Reboot(-Time)? '→ Automatic-Reboot "true" and Automatic-Reboot-Time "04:00"
    swapon --show→ /swapfile file 2G
    sudo docker run --rm hello-world | grep Hello→ Hello from Docker!
    2Protection
    sudo docker exec crowdsec cscli bouncers list→ firewall-bouncer, with Last API pull seconds ago
    sudo nft list table ip crowdsec | grep hook→ two lines: hook input and hook forward
    sudo docker exec crowdsec cscli metrics show acquisition→ a file:/var/log/auth.log line with non-zero numbers
    sudo ss -tlnH | awk '{print $4}' | grep -v -e '^127\.' -e '^\[::1\]'→ only :22; after level 3, :80 and :443 as well
    3Services
    sudo docker ps --filter name=traefik --format '{{.Names}} {{.Status}}'→ traefik Up …
    curl -sI http://whoami.example.org | head -1→ HTTP/1.1 308 Permanent Redirect
    echo | openssl s_client -connect whoami.example.org:443 -servername whoami.example.org 2>/dev/null | openssl x509 -noout -issuer→ issuer says Let's Encrypt
    curl -m 5 -s http://203.0.113.10:5230 || echo closed→ closed: memos is reachable only by name
    4Observability
    sudo docker ps --format '{{.Names}} {{.Status}}' | grep -E '^(beszel|beszel-agent|gatus) '→ three lines, each Up …
    curl -s -o /dev/null -d 'Test from web1' ntfy.sh/$(sudo cat /srv/secrets/ntfy/topic)→ “Test from web1” on your phone
    cd /opt/memos && sudo docker compose stop→ a Gatus alert about memos within 3–4 minutes; after sudo docker compose start, a note that it answers again
    sudo ss -tlnH | awk '{print $4}' | grep -v -e '^127\.' -e '^\[::1\]'→ still only :22, :80 and :443: monitoring opened nothing to the outside
    5Backups
    systemctl list-timers 'kopia-*'→ two timers, kopia-backup.timer and kopia-verify.timer, both with NEXT filled in
    sudo kopia snapshot list --all→ root@web1:/opt and root@web1:/srv/secrets, each with snapshots from the last nights
    sudo systemctl start kopia-verify.service→ returns without an error after a few minutes, the web1-verify check in Healthchecks.io is up
    Healthchecks.io, the `web1-backup` check→ up, last ping today around 03:00
    6Migration
    sudo git -C /opt status --short→ nothing: everything that belongs in git is committed
    sudo git -C /opt ls-files host scripts→ host/bootstrap.sh, host/authorized_keys, files under host/etc/ and scripts/restore.sh
    curl -s -o /dev/null -w '%{http_code}\n' --resolve memos.example.org:443:203.0.113.20 https://memos.example.org→ 200 from a server brought up from git and the backup: in a drill, from the temporary VPS
    7Automation
    systemctl list-timers deploy.timer→ one timer, with NEXT no more than 10 minutes away
    curl -s https://whoami.example.org | grep Name→ Name: from-git: a change from your computer reached the server without an SSH login
    sudo grep -h 'image:' /opt/*/docker-compose.yaml→ every image has @sha256:…: Renovate manages the versions
    Continue with level 1, “Base”The recipe “New server: the first hour” starts from an empty VPS.
    To the level 1 recipe

    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.

    WhatWhere and how
    Stack/opt/<stack>/docker-compose.yaml — a directory of its own for every service
    Nameone for everything: directory /opt/memos, container memos, Traefik router memos, address memos.example.org
    Data/opt/<stack>/data/, in compose — ./data:…
    Secretsas 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
    Networkproxy, external: create it once; Traefik and every service it exposes join it
    Open portsonly 22, 80 and 443; services have no ports:, they’re reached by name through Traefik
    Userexample-user with sudo, key login; root can’t log in over SSH; recipe commands run with sudo
    Request log/opt/traefik/data/logs/access.log, JSON
    Scriptsfor the whole server — /opt/scripts/, for one stack — in its directory
    Your valuesemail [email protected], domain example.org, server address 203.0.113.10, user example-user, server name web1, backup server address 198.51.100.20You can enter your own
    Why it’s this way and how to check your server