source: Klonkt/README.md@ f79a471

main
Last change on this file since f79a471 was 897c33b, checked in by Robin Genis <roboburr@…>, 2 months ago

docs(readme): document the HSTS_STRICT env var

  • Property mode set to 100644
File size: 7.9 KB
Line 
1# Klonkt
2
3Your own, **self-hosted** corner of the web — for your story, your visuals and
4your sound. Built on **Node + SQLite + htmx**: lightweight, server-rendered, and
5yours. No algorithm, no ads, no platform sitting in between.
6
7## What it does
8
9- **Solo** — one personal site, entirely yours, on your own domain.
10- **Blog & photos** — posts with cover, tags, timeline or grid.
11- **Host your own music** — built-in audio player with tracks, albums and playlists.
12- **Fediverse-native** — your posts federate over **ActivityPub**: people follow,
13 like, boost and reply from Mastodon (or another Klonkt). You can follow accounts,
14 see a home timeline, and reply/like back — Klonkt is a full fediverse client.
15- **Grow**: newsletter, download-for-email, EPK/press kit, link-in-bio,
16 show calendar, and **cookie-free statistics**.
17- **Circles** — a curated feed of the makers you choose: feature accounts (other Klonkt
18 sites, Mastodon, PeerTube — any fediverse server) and their public posts appear in your
19 Circle. Decentralized, no central platform — built on ActivityPub.
20- **Themes & languages** — multiple palettes (light + dark), interface in EN/NL/DE.
21- **Installable (PWA)**, **privacy-first** (self-hosted fonts, no tracking).
22
23### Lite mode (no audio)
24
25Set `KLONKT_AUDIO=off` in `.env` to disable the entire audio/music feature.
26Klonkt then runs as a lightweight **blog/photo/EPK/links site without ffmpeg** —
27ideal for minimal hosting. Circles and external embeds
28(YouTube/SoundCloud/Spotify) keep working.
29
30It's **fully reversible**: set `KLONKT_AUDIO` back to `on` (or remove the line)
31and restart — no reinstall. The flag only toggles the audio routes/UI; the
32database tables are never dropped, so any tracks you had are preserved.
33
34## Self-hosting
35
36Klonkt is a **Node app** — run it on a **VPS, in Docker, or on a Node hosting
37platform (PaaS)**. **Not** on classic shared PHP hosting. The database (SQLite)
38creates itself on first start.
39
40> **Requires [Node.js](https://nodejs.org/) 20 or newer.** The one-command VPS
41> installer and the Docker image include it; only a manual install needs you to
42> provide it.
43
44### Option A — One-command VPS installer (recommended)
45
46**Good if:** you have (or just rented) a fresh, empty Debian/Ubuntu VPS and want
47the easiest path. This single line does everything — installs Node 20, sets up
48Caddy for automatic HTTPS, runs Klonkt as a background service that auto-restarts
49on reboot, and adds an update command. It's coexistence-safe (if the server
50already runs something it picks a free port and skips Caddy), but a clean VPS is
51simplest. Point your domain's DNS (A + AAAA records) at the server first, then run
52as root:
53
54```bash
55curl -fsSL https://klonkt.com/install.sh | sudo bash -s -- --domain yourdomain.com
56```
57
58Then open `https://yourdomain.com` and finish setup in the browser. Update anytime
59with `klonkt-update`.
60
61### Option B — Docker
62
63**Good if:** you already use Docker, or want everything bundled in one isolated
64container. Node, ffmpeg and cwebp are inside the image — you only need Docker +
65Docker Compose.
66
67```bash
68git clone https://github.com/roboburr/klonkt.git
69cd klonkt
70cp .env.example .env # works as-is; optionally set PUBLIC_BASE_URL to your domain
71docker compose up -d
72```
73
74`SESSION_SECRET` is auto-generated on first start, so the defaults work as-is.
75Klonkt runs on port 3000 — put your own reverse proxy in front for HTTPS (see
76step 5 of Option C). Data (database + media) stays in the `klonkt-data` volume,
77even across updates. Update: `git pull && docker compose up -d --build`.
78
79### Option C — manual (Node 20+), step by step
80
81**Good if:** you want full control, are adding Klonkt to a server you already
82manage, or just want to test it locally.
83
84**1. Get the code & install dependencies**
85
86```bash
87git clone https://github.com/roboburr/klonkt.git
88cd klonkt
89npm ci
90```
91
92**2. Create your config.** `SESSION_SECRET` (the key that signs login cookies) is
93auto-generated on first start, so this works as-is. For production, set
94`PUBLIC_BASE_URL` to your site address (e.g. `https://yourdomain.com`) so email &
95login links are correct:
96
97```bash
98cp .env.example .env
99nano .env # optional: PUBLIC_BASE_URL, plus SMTP if you want it
100```
101
102**3. Start it** — the SQLite database is created automatically on first start:
103
104```bash
105npm start # runs on http://localhost:3000
106```
107
108Just testing locally? Stop here and open `http://localhost:3000`.
109
110**4. Keep it running** across crashes and reboots (easiest is pm2):
111
112```bash
113npm install -g pm2
114pm2 start src/server.js --name klonkt
115pm2 save && pm2 startup # run the one command it prints, once
116```
117
118**5. Add HTTPS** with a reverse proxy in front. With Caddy (automatic
119certificates), put this in `/etc/caddy/Caddyfile` and reload Caddy:
120
121```caddy
122yourdomain.com {
123 reverse_proxy localhost:3000
124}
125```
126
127By default the app binds to `127.0.0.1` (via `HOST` in `.env`), so only your
128reverse proxy can reach it — not the open internet. Local testing on the same
129machine (`localhost:3000`) still works. Only set `HOST=0.0.0.0` if you need direct
130external access without a proxy (then open the port in your firewall and add HTTPS
131yourself).
132
133(`cwebp` is optional — `apt install webp` — for WebP image conversion.)
134
135### HTTPS (Docker / bare Node)
136
137Put a reverse proxy in front of the app. With **Caddy** (automatic Let's Encrypt):
138
139```caddy
140yourdomain.com {
141 reverse_proxy localhost:3000
142 encode gzip zstd
143}
144```
145
146(The VPS installer sets up Caddy + HTTPS for you already.)
147
148### First run
149
150Open your site → you get the **setup wizard**: pick your language, name your site
151and create your admin. The **first user automatically becomes the administrator**;
152registration then closes. Lost your password?
153`npm run reset-admin` (Docker: `docker compose exec klonkt npm run reset-admin`).
154
155## Configuration (`.env`)
156
157| Variable | Required | What |
158|---|---|---|
159| `SESSION_SECRET` | ✅ | Random string of ≥32 characters |
160| `PUBLIC_BASE_URL` | ✅ | Canonical URL (e.g. `https://yourdomain.com`) |
161| `SMTP_HOST` / `_PORT` / `_USER` / `_PASS` / `_FROM` | — | Email for password reset + newsletter |
162| `KLONKT_DEFAULT_LANG` | — | Default language for visitors (`en`/`nl`/`de`) |
163| `KLONKT_AUDIO` | — | `off` = lite mode (no audio/ffmpeg) |
164| `HSTS_STRICT` | — | `1` = stricter HTTPS header (`includeSubDomains` + `preload`). Only set this if Klonkt owns the **whole** domain and all its subdomains are HTTPS — it forces every subdomain to HTTPS and can bake your domain into browsers near-permanently. Leave unset otherwise; the default is already safe. |
165
166## Stack
167
168- **Runtime:** Node 20+
169- **Web:** Express + Helmet + express-session
170- **DB:** better-sqlite3 (WAL), self-migrating on boot
171- **Templates:** EJS (server-rendered) + **htmx 1.9** (vendored, no build step)
172- **Audio:** ffmpeg-static (bundled)
173- **Fediverse / Circles:** ActivityPub (HTTP Signatures) — federates with Mastodon, PeerTube and other Klonkt sites
174- **Fonts:** self-hosted variable woff2 (Fraunces / Plus Jakarta Sans)
175
176## Project structure
177
178```
179src/
180├── server.js # Express bootstrap + route mounting
181├── config/ # database, mailer, feature flags
182├── db/migrations/ # SQLite schema (001-init.sql)
183├── middleware/ # site resolving, auth, render (htmx-aware)
184├── routes/ # per-resource Express routers (posts, auth, admin-*, circle, …)
185├── services/ # domain logic (federation, stats, mailer, permissions, …)
186├── views/ # shell.ejs + partials/ + pages/ (EJS)
187└── assets/ # css/ (palette tokens + components), js/ (htmx, player), fonts/
188```
189
190## License
191
192**AGPL-3.0-or-later** — see [LICENSE](LICENSE). Klonkt is free software: you may
193use, study, modify and distribute it. The AGPL does require that a modified
194version you offer as a network service makes its source code available to the
195users of that service. Made by robo.burr (Robin Genis) ·
196<https://klonkt.com>
Note: See TracBrowser for help on using the repository browser.